Re: [NTG-context] Implicit plots/level curves possible?

2018-10-09 Thread Alan Braslau
n,llcorner pic) ; label.lft(decimal ymax,ulcorner pic) ; \stopuseMPgraphic \unexpanded\def\ContourPlot {\dosingleempty\doContourPlot} \def\doContourPlot[#1]% {\setvariables [ContourPlot] [x={0,0}, y={0,0}, w=10cm, n=1000, e=1e-2, #1]% \ctxl

Re: [NTG-context] Implicit plots/level curves possible?

2018-10-08 Thread Aditya Mahajan
oContourPlot[#1]% {\setvariables[ContourPlot][#1]% \ctxlua{userdata.contourplot( function(x,y) return \getvariable{ContourPlot}{function} end, {\getvariable{ContourPlot}{x}}, {\getvariable{ContourPlot}{y}}, \getvariable{ContourPlot}{n})}% \useMPgraphic{doublef

Re: [NTG-context] linking to an external PDF file

2018-10-08 Thread Pablo Rodriguez
der Meer. Sorry, but I’m afraid I don’t see the way of generating an URL to a non-external document in your code. After all, the document is embedded in the PDF document itself. Pablo > % Return the code when clicking the link. > \def\URIReturnCode#1{\ctxlua{tex.print(hvdm.ur

Re: [NTG-context] linking to an external PDF file

2018-10-08 Thread Hans van der Meer
I am embedding links to an UR in my documents. Although it is used in XML-documents, you might be able to use the gist of this code that generates a clickable link. Perhaps you find it useful. dr. Hans van der Meer % Return the code when clicking the link. \def\URIReturnCode#1{\ctxlua

Re: [NTG-context] context and sqlite - here is the code

2018-10-07 Thread Jörg Hofmann
[C]: in function 'requiem' ...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:180: in function <...live/2017/texmf-dist/tex/context/base/mkiv/l-sandbox.lua:165> (...tail calls...)

Re: [NTG-context] accessing glyphs in the private area

2018-10-01 Thread Ulrike Fischer
is there no problem? > you can define > > \def\byindex#1{\ctxlua{ > for k, v in pairs(fonts.hashes.identifiers[true].characters) do > if v.index == #1 then > tex.print(utf.char(k)) > break > end > end > }} &g

Re: [NTG-context] accessing glyphs in the private area

2018-10-01 Thread Hans Hagen
in your case the glyphs have no real useful names so basically i wonder what their use it (are they meant for direct access?) you can define \def\byindex#1{\ctxlua{ for k, v in pairs(fonts.hashes.identifiers[true].characters) do if v.index == #1 then tex.print(utf.

Re: [NTG-context] Metafun: Finding intersection between characters

2018-09-22 Thread Hans Hagen
ctor)             return paths         end     end end \stopluacode \def\mpdefineoutlines#1#2{\ctxlua{     local char = "\luaescapestring{#1}"     local outlines = outlinepaths("#2")     local len = \letterhash outlines     tex.print("path " .. char .. "[];&q

Re: [NTG-context] Metafun: Finding intersection between characters

2018-09-22 Thread Alan Braslau
nicode > >>>     local shapeglyphs = shapedata.glyphs or { } > >>>     character = utf.byte(character) > >>>     local c = chardata[character] > >>>     if c then > >>>         if not c.index then > >>>             return {} >

Re: [NTG-context] Metafun: Finding intersection between characters

2018-09-22 Thread Hans Hagen
(glyph.segments or glyph.sequence) then             local units  = shapedata.units or 1000             local factor = 100/units             local paths  = fonts.metapost.paths(glyph,factor)             return paths         end     end end \stopluacode \def\mpdefineoutlines#1#2{\ctxlua{    

Re: [NTG-context] Metafun: Finding intersection between characters

2018-09-22 Thread Floris van Manen
if c then >> if not c.index then >> return {} >> end >> local glyph = shapeglyphs[c.index] >> if glyph and (glyph.segments or glyph.sequence) then >> local units = shapedata.units or 1000 >>

Re: [NTG-context] Metafun: Finding intersection between characters

2018-09-22 Thread Hans Hagen
h and (glyph.segments or glyph.sequence) then local units = shapedata.units or 1000 local factor = 100/units local paths = fonts.metapost.paths(glyph,factor) return paths end end end \stopluacode \def\mpdefineoutlines#1#2{\c

[NTG-context] Metafun: Finding intersection between characters

2018-09-22 Thread Henri Menke
local units = shapedata.units or 1000 local factor = 100/units local paths = fonts.metapost.paths(glyph,factor) return paths end end end \stopluacode \def\mpdefineoutlines#1#2{\ctxlua{ local char = "\luaescapestring{#1}"

Re: [NTG-context] how to set the name of outputfile using a value defined in the source

2018-09-21 Thread Hans Hagen
sneakily … % start demo \enabledirectives[system.callbacks.permitoverloads] % previous line allows redefinition of ‘wrapup_run’ % to keep the code short, I use a direct definition of % \idcode and \ctxlua. Nicer would be to store the desired % output name in a lua variable and replace the % \

Re: [NTG-context] how to set the name of outputfile using a value defined in the source

2018-09-21 Thread Taco Hoekwater
>>>> Is this possible? >>> >>> Once you enter TeX, the output file has been opened. The very concept >>> of a filesystem forbids you to change the filehandle while writing. So >>> no, it is not possible easily. >> >> But it can be done

Re: [NTG-context] how to set the name of outputfile using a value defined in the source

2018-09-21 Thread J Huisman
very concept > > of a filesystem forbids you to change the filehandle while writing. So > > no, it is not possible easily. > > But it can be done sneakily … > > > % start demo > \enabledirectives[system.callbacks.permitoverloads] > % previous line allows redefinition of

Re: [NTG-context] how to set the name of outputfile using a value defined in the source

2018-09-21 Thread Taco Hoekwater
TeX, the output file has been opened. The very concept > of a filesystem forbids you to change the filehandle while writing. So > no, it is not possible easily. But it can be done sneakily … % start demo \enabledirectives[system.callbacks.permitoverloads] % previous line allows redefin

Re: [NTG-context] Problem with simplefonts

2018-08-30 Thread Wolfgang Schuster
nts/t-simplefonts.mkiv: ! Undefined control sequence \simplefonts@fontfeature ...\normalexpanded {\@NX \definefontfeature [#1#2\s... \syst_helpers_comma_list_step ...\v!mainfont }{#1} \ctxlua {thirddata.simplef... \17>>2 #1,->\syst_helpers_com

Re: [NTG-context] Problem with simplefonts

2018-08-30 Thread Hans Hagen
: ! Undefined control sequence \simplefonts@fontfeature ...\normalexpanded {\@NX \definefontfeature [#1#2\s... \syst_helpers_comma_list_step ...\v!mainfont }{#1} \ctxlua {thirddata.simplef... \17>>2 #1,->\syst_helpers_comma_l

[NTG-context] Problem with simplefonts

2018-08-30 Thread Mari Voipio
{\@NX \definefontfeature [#1#2\s... \syst_helpers_comma_list_step ...\v!mainfont }{#1} \ctxlua {thirddata.simplef... \17>>2 #1,->\syst_helpers_comma_list_step {#1}

Re: [NTG-context] future versions - synctex

2018-08-21 Thread Hans Hagen
itles of sections: they go via lua so there we already need to cheat input registration) In this approach - "boxes" generated by Lua-in-ConTeXt should "jump" on \startluacode, \ctxlua, \cldcommand statement... won't happen ... way too much overhead and it would polut

Re: [NTG-context] future versions - synctex

2018-08-21 Thread Procházka Lukáš Ing .
synctex file is nornally okay unless we render from lua, which happens for instance with titles. Just try \ctxlua{context("foo bar")} and you will also see that there is no line related positioning. Tweaking luatex for this is not really an options because whatever decision we make here wi

Re: [NTG-context] How can I remove a blank leading line from a buffer

2018-08-16 Thread Aditya Mahajan
ntext(userdata.strip(buffers.getcontent('name))) local s = [[ foo bar bar ]] print(string.fullstrip(s)) So, it looks likethe following is closer to working for me in a simple test harness, but not in my full-blown work: \dontleavehmode{\llap{StripA~}}\ctxlua{context(utilities.strin

Re: [NTG-context] How can I remove a blank leading line from a buffer

2018-08-15 Thread Rik Kabel
ame))) local s = [[ foo bar bar ]] print(string.fullstrip(s)) So, it looks likethe following is closer to working for me in a simple test harness, but not in my full-blown work: \dontleavehmode{\llap{StripA~}}\ctxlua{context(utilities.strings.striplines(string.gsub(buffers.getconten

Re: [NTG-context] XML to ConTeXt: converting date attribute from ISO date

2018-08-15 Thread Hans Hagen
e \xmlsetsetup{#1}{date}{xml:date} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:date \xmldoifelse {#1}{.[@type='divDate']} { \def\docdate{\ctxlua{ local tyear = string.sub('\xmlatt{#1}{when-iso}',1,4) local tmonth = string.sub('\xmlatt{#1}{when-iso}

[NTG-context] XML to ConTeXt: converting date attribute from ISO date

2018-08-15 Thread Mike O'Connor
xmlsetsetup{#1}{date}{xml:date} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:date \xmldoifelse {#1}{.[@type='divDate']} { \def\docdate{\ctxlua{ local tyear = string.sub('

Re: [NTG-context] date calculated with currentdate plus n days

2018-08-14 Thread Henri Menke
On 14/08/18 17:29, Pablo Rodriguez wrote: On 08/14/2018 01:46 AM, Henri Menke wrote: On top of that I recommend to use context.date to get the correct formatting according to the current language options: \def\duedate{\ctxlua{ local t = os.date('*t', os.time()+ 10 *

Re: [NTG-context] date calculated with currentdate plus n days

2018-08-13 Thread Pablo Rodriguez
On 08/14/2018 01:46 AM, Henri Menke wrote: > On top of that I recommend to use context.date to get the correct > formatting according to the current language options: > > \def\duedate{\ctxlua{ >local t = os.date('*t', os.time()+ 10 * 24 * 3600) >context.dat

Re: [NTG-context] date calculated with currentdate plus n days

2018-08-13 Thread Henri Menke
On top of that I recommend to use context.date to get the correct formatting according to the current language options: \starttext \def\duedate{\ctxlua{ local t = os.date('*t', os.time()+ 10 * 24 * 3600) context.date{ d = t.day, m = t.month, y = t.year } }} \duedate \stoptext

Re: [NTG-context] integer displayed as .0 float in Lua-5.3

2018-08-11 Thread Pablo Rodriguez
number where so dependent on the Lua version. > That said > ... > > \startTEXpage[offset=1em] > \ctxlua{context([[\lastpage]])}. > \stopTEXpage > > Why do you convert \lastpage to a string using [[\lastpage]] which will > use the string to number conversion? Well,

Re: [NTG-context] integer displayed as .0 float in Lua-5.3

2018-08-09 Thread Hans Hagen
... \startTEXpage[offset=1em] \ctxlua{context([[\lastpage]])}. \stopTEXpage Why do you convert \lastpage to a string using [[\lastpage]] which will use the string to number conversion. In fact this automatic cast from string to number in an addition might disappear from the language in the future so don&#

Re: [NTG-context] integer displayed as .0 float in Lua-5.3

2018-08-09 Thread Wolfgang Schuster
rtTEXpage[offset=1em] Pages: \ctxlua{context([[\lastpage]])}. Next page: \ctxlua{context([[\lastpage]] + 1)}. (Lua \luaversion) \stopTEXpage \stoptext With Lua-5.2 (ConTeXt with JIT), I get the expected results. But with Lua-5.3 (standard ConTeXt), I get 2.0 as the value for

[NTG-context] integer displayed as .0 float in Lua-5.3

2018-08-09 Thread Pablo Rodriguez
Dear list, I have the following sample \starttext \startTEXpage[offset=1em] Pages: \ctxlua{context([[\lastpage]])}. Next page: \ctxlua{context([[\lastpage]] + 1)}. (Lua \luaversion) \stopTEXpage \stoptext With Lua-5.2 (ConTeXt with JIT), I get the expected results

Re: [NTG-context] about the defining itemized columns.

2018-07-26 Thread Hans Hagen
possible to define a one definition which can be set by argument as following. \define[1]\iCol{\starttabulate[|*{#1}{|lw(.84/#1)\makeupwidth|}]} When I call it \iCol{2}, the first *{#1} is working, but the second #1 is a problem. I tried \ctxlua for division, but it didn’t work either. Is there a nice

[NTG-context] about the defining itemized columns.

2018-07-26 Thread Jeong Dal
can be set by argument as following. \define[1]\iCol{\starttabulate[|*{#1}{|lw(.84/#1)\makeupwidth|}]} When I call it \iCol{2}, the first *{#1} is working, but the second #1 is a problem. I tried \ctxlua for division, but it didn’t work either. Is there a nice way to define them in one definition

Re: [NTG-context] future versions

2018-07-24 Thread Hans Hagen
synchronization and/or adapt to a macro package. Anyway, were sort of stuck and can only try to make the best of it. That said, the context generated synctex file is nornally okay unless we render from lua, which happens for instance with titles. Just try \ctxlua{context("foo bar")} an

Re: [NTG-context] SHA512 for LuaTeX-5.2

2018-07-23 Thread Hans Hagen
{\ctxlua{context(utilities.sha2.hash512("#1"))}} \hashfive{a} \stoptext ConTeXt complains: [ctxlua]:1: attempt to index field 'sha2' (a nil value) What am I doing wrong? require("util-sha") Many thanks for your reply, Hans. It works like a charm

Re: [NTG-context] SHA512 for LuaTeX-5.2

2018-07-23 Thread Pablo Rodriguez
On 07/23/2018 05:42 PM, Hans Hagen wrote: > On 7/23/2018 4:51 PM, Pablo Rodriguez wrote: >> On 07/22/2018 10:56 PM, Hans Hagen wrote: >>> why not use >>> >>> utilities.sha2.hash512(str) >> >> Many thanks for your reply, Hans. >> >

Re: [NTG-context] SHA512 for LuaTeX-5.2

2018-07-23 Thread Hans Hagen
On 7/23/2018 4:51 PM, Pablo Rodriguez wrote: On 07/22/2018 10:56 PM, Hans Hagen wrote: why not use utilities.sha2.hash512(str) Many thanks for your reply, Hans. \starttext \def\hashfive#1{\ctxlua{context(utilities.sha2.hash512("#1"))}} \hashfive{a} \stoptex

Re: [NTG-context] SHA512 for LuaTeX-5.2

2018-07-23 Thread Pablo Rodriguez
On 07/22/2018 10:56 PM, Hans Hagen wrote: > why not use > > utilities.sha2.hash512(str) Many thanks for your reply, Hans. \starttext \def\hashfive#1{\ctxlua{context(utilities.sha2.hash512("#1"))}} \hashfive{a} \stoptext ConTeXt complains: [ctxlua]:1: att

[NTG-context] SHA512 for LuaTeX-5.2

2018-07-22 Thread Pablo Rodriguez
the message in successive 1024-bit (128 bytes) chunks: for i = 1, #msg, 128 do digestblock(msg, i, H) end context finalresult512(H) end \stoplua \def\hashfive#1{\ctxlua{hash512("#1")}} \hashfive{a} \stoptext ✂️--

Re: [NTG-context] page ranges in \markpage

2018-07-19 Thread Hans Hagen
[" .. tag .. "][" .. table.concat(page_array, ", ") .. "]") end \stopluacode \def\getmarkedpageranges#1#2{% \ctxlua{document.printmarkedpageranges("#1","#2")}} \setuplayout[page] \setupinteraction[st

Re: [NTG-context] page ranges in \markpage

2018-07-19 Thread Pablo Rodriguez
t;\\markpage[" .. tag .. "][" .. table.concat(page_array, ", ") .. "]") end \stopluacode \def\getmarkedpageranges#1#2{% \ctxlua{document.printmarkedpageranges("#1","#2")}} \setuplayout[page] \setupinteraction

[NTG-context] setmemstream to use pdfe.new instead of epdf.openMemStream

2018-06-23 Thread Adam Reviczky
f/tex/context/base/mkiv/grph-mem.lua:32: attempt to index global 'epdf' (a nil value) stack traceback: /usr/share/texmf/tex/context/base/mkiv/grph-mem.lua:32: in function 'setmemstream' [ctxlua]:2: in main chunk Which points to the line of "local memstream, ide

[NTG-context] libcurl via FFI

2018-05-17 Thread Henri Menke
local c_http_code = ffi.new("long[1]") assert(CURLE_OK == lcurl.curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, c_http_code)) -- End a libcurl easy handle lcurl.curl_easy_cleanup(curl) -- Convert C long* to Lua number return tonumber(c_http_code[0]) end \sto

Re: [NTG-context] Files on a server

2018-05-17 Thread Henri Menke
long long, void*)> to cdata >> stack traceback: >> [C]: in function 'curl_easy_setopt' >> [ctxlua]:42: in function 'check_status' >> [ctxlua]:1: in main chunk >> >> And I have no idea what that actually means or how to fix it? >

Re: [NTG-context] Files on a server

2018-05-17 Thread Taco Hoekwater
.cast("callback",discard)); > > If I dont, I get an error message from ffi that is: > > unable to convert argument 3 from cdata unsigned long long, unsigned long long, void*)> to cdata > stack traceback: > [C]: in function 'curl_easy_setopt' >

Re: [NTG-context] Files on a server

2018-05-17 Thread Taco Hoekwater
;callback",discard)); If I dont, I get an error message from ffi that is: unable to convert argument 3 from cdata to cdata stack traceback: [C]: in function 'curl_easy_setopt' [ctxlua]:42: in function 'check_

Re: [NTG-context] Files on a server

2018-05-16 Thread Hans Hagen
e 0 in file : ...-45/tex/texmf-context/tex/context/base/mkiv/core-uti.lua:92: attempt to index a number value (global 'status') ? Process aborted Code in tex: \def\URIReturnCode#1{\ctxlua{tex.print(hvdm.urireturncode("#1"))}} \verbose{HVDM-PEV-TEST}{return code: \URIR

Re: [NTG-context] Files on a server

2018-05-16 Thread Hans van der Meer
5/tex/texmf-context/tex/context/base/mkiv/core-uti.lua:92: attempt to index a number value (global 'status') ? Process aborted Code in tex: \def\URIReturnCode#1{\ctxlua{tex.print(hvdm.urireturncode("#1"))}} \verbose{HVDM-PEV-TEST}{return code: \URIRe

Re: [NTG-context] Files on a server

2018-05-16 Thread Taco Hoekwater
.curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, > ffi.cast("callback",discard)); > >local res = lcurl.curl_easy_perform(curl) >local c_http_code = ffi.new("long[1]") >lcurl.curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, c_http_code); > >lcurl.curl_easy_

Re: [NTG-context] Files on a server

2018-05-16 Thread Henri Menke
_WRITEFUNCTION, ffi.cast("callback",discard)); local res = lcurl.curl_easy_perform(curl) local c_http_code = ffi.new("long[1]") lcurl.curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, c_http_code); lcurl.curl_easy_cleanup(curl) lcurl.curl_global_cleanup() return to

Re: [NTG-context] Problem with Filter Module in latent context beta

2018-04-16 Thread Hans Hagen
eback:     [C]: in function 'string.find' ...inimals/texmf-context/tex/context/base/mkiv/file-res.lua:147: in upvalue 'action1'     [string "local action = tokens._action..."]:4: in field 'getreadfilename'     [ctxlua]:1: in main

Re: [NTG-context] Problem with Filter Module in latent context beta

2018-04-16 Thread Aditya Mahajan
...inimals/texmf-context/tex/context/base/mkiv/file-res.lua:147: in upvalue 'action1' [string "local action = tokens._action..."]:4: in field 'getreadfilename' [ctxlua]:1: in main chunk Not sure why #1

Re: [NTG-context] typesetting information from git

2018-02-23 Thread Schmitz Thomas A.
ment.jobfilefullname) or "") > } > > \stopluacode > > \setupfootertexts > [this is from file: \documentvariable{gitversion}] > > \starttext > > [[\ctxlua{context(environment.jobfilefullname)}]] > > [[\ctxlua{context(environment.jobfilename)}]] > > \ctxl

Re: [NTG-context] typesetting information from git

2018-02-23 Thread Hans Hagen
mean \startluacode context.setupdocument { gitversion = string.strip( os.resultof("git --no-pager log --pretty='%h of %aD' -1 " .. environment.jobfilefullname) or "") } \stopluacode \setupfootertexts [this is from file: \documentva

Re: [NTG-context] image file resolver in Lua?

2018-02-20 Thread Henning Hraban Ramm
th \NC \figurefilepath \NC \NR > \NC \string\figurefilename \NC \figurefilename \NC \NR > \NC \string\figurefiletype \NC \figurefiletype \NC \NR > \stoptabulate Next try: How can I access these values from Lua? While \ctxlua{print("\figureheight&

Re: [NTG-context] To \getbuffer or to \input: which one is it better?

2018-02-11 Thread Hans Hagen
context.NC() context("Location and Time") context.EQ() context("Room %s at %s",d.room,d.time) context.NC() context.NR() context.HL() end context.stoptabulate() end \sto

Re: [NTG-context] Sending data from lua to context and back to lua

2018-02-08 Thread Rudolf Bahr
my imagination there must be > > variables in both languages where the sent data is to be found. > > > > With the use of "\immediate\write" and "\read" in context and the read and > > write > > functions in lua I know exactly from where to wh

Re: [NTG-context] Sending data from lua to context and back to lua

2018-02-08 Thread Henning Hraban Ramm
; and "\read" in context and the read and > write > functions in lua I know exactly from where to where the data goes. How to do > the same with "context()"? \startluacode function SomeFunction() context("Value") end \stopluacode \def\MyVar{\ctxlua{SomeFun

Re: [NTG-context] image file resolver in Lua?

2018-02-05 Thread Rudolf Bahr
y (convoluted) placement macro: > > > > > > % image on empty page, caption in margin > > > % usage: > > > % \startpostponing[pagenumber] > > > % \pagefig[reference]{caption}{filename} > > > % \stoppostponing > > > % postponing is impor

Re: [NTG-context] image file resolver in Lua?

2018-02-04 Thread Hans Hagen
important, otherwise the page numbering gets wrong \def\pagefig{\dosingleempty\doPagefig} \def\doPagefig[#1]#2#3{ % calculate image size \startfullpagemakeup \externalfigure[#3][width=1mm] % dummy to set image as current \def\myClipHeight{\ctxlua{ctxClipHeight("#3", \Resolution)}} \

Re: [NTG-context] image file resolver in Lua?

2018-02-02 Thread Rudolf Bahr
tponing is important, otherwise the page numbering gets wrong > \def\pagefig{\dosingleempty\doPagefig} > \def\doPagefig[#1]#2#3{ > % calculate image size > \startfullpagemakeup > \externalfigure[#3][width=1mm] % dummy to set image as current > \def\myClipHeight{\ctxlua{ctxC

Re: [NTG-context] image file resolver in Lua?

2018-02-02 Thread Henning Hraban Ramm
stoppostponing % postponing is important, otherwise the page numbering gets wrong \def\pagefig{\dosingleempty\doPagefig} \def\doPagefig[#1]#2#3{ % calculate image size \startfullpagemakeup \externalfigure[#3][width=1mm] % dummy to set image as current \def\myClipHeight{\ctxlua{ctxClipHeight(&q

Re: [NTG-context] Word and character count excluding TeX-directives

2018-01-16 Thread Rik Kabel
context(w.total)     end     context.par()     end     end     end \stopluacode \def\wordcount{%     \dosingleempty\dowordcount} \def\dowordcount[#1]{%     \ctxlua{userdata.wordcount("#1")}} \setupspellchecking[st

Re: [NTG-context] Problem with string.format (Lua)

2018-01-14 Thread Hans Hagen
On 1/14/2018 9:50 PM, Fabrice Couvreur wrote: Hi Hans, Your code runs perfectly, thanks. However, if I replace % with \letterpercent, my code does not run \ctxlua{print(string.format("\letterpercent g",Binomial(100,60,0.25)))} because print prints to the console Thank you Fab

Re: [NTG-context] Problem with string.format (Lua)

2018-01-14 Thread Fabrice Couvreur
Hi Hans, Your code runs perfectly, thanks. However, if I replace % with \letterpercent, my code does not run \ctxlua{print(string.format("\letterpercent g",Binomial(100,60,0.25)))} Thank you Fabrice 2018-01-14 13:58 GMT+01:00 Hans Hagen : > On 1/14/2018 1:13 PM, Joseph Canedo w

Re: [NTG-context] Problem with string.format (Lua)

2018-01-14 Thread Hans Hagen
; n then return nil end     if k > n/2 then k = n - k end     numer, denom = 1, 1     for i = 1, k do     numer = numer * ( n - i + 1 )     denom = denom * i     end     return (numer/denom) * p^k * (1-p)^(n-k) end \stopluacode \starttext \ctxlua{print(string.format("%

Re: [NTG-context] Problem with string.format (Lua)

2018-01-14 Thread Joseph Canedo
n - i + 1 )     denom = denom * i     end     return (numer/denom) * p^k * (1-p)^(n-k) end \stopluacode \starttext \ctxlua{print(string.format("%g",Binomial(100,60,0.25)))} \stoptext ___ If your question i

[NTG-context] Problem with string.format (Lua)

2018-01-14 Thread Fabrice Couvreur
n - i + 1 ) denom = denom * i end return (numer/denom) * p^k * (1-p)^(n-k) end \stopluacode \starttext \ctxlua{print(string.format("%g",Binomial(100,60,0.25)))} \stoptext ___ If your question i

Re: [NTG-context] German letter style

2017-12-05 Thread Henning Hraban Ramm
o 'gmatch' (string expected, got nil) > stack traceback: > [C]: in function 'gmatch' > ...eXt/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:47: in > function 'registercode' > [ctxlua]:1: in main chunk > > 20 %C MERCHANT

Re: [NTG-context] German letter style

2017-12-05 Thread Floris van Manen
ex/texmf-modules/tex/context/third/letter/base/s-cor-00.mkvi' lua error > lua error on line 30 in file /Applications/ConTeXt/tex/texmf-modules/tex/context/third/letter/base/s-cor-00.mkvi: ...eXt/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:47: bad argument #1 to 'gm

Re: [NTG-context] 'lua.registercode' bug in latest beta

2017-11-26 Thread Hans Hagen
ontext/tex/context/base/mkiv/luat-cod.lua:50: bad argument #1 to 'gmatch' (string expected, got nil) stack traceback: [C]: in function 'gmatch' ...ctx/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:50: in function 'registercode' [ctxlua]:

Re: [NTG-context] 'lua.registercode' bug in latest beta

2017-11-26 Thread Marco Patzer
ot nil) stack traceback: [C]: in function 'gmatch' ...ctx/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:50: in function 'registercode' [ctxlua]:1: in main chunk 20 %C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 %C GNU G

Re: [NTG-context] 'lua.registercode' bug in latest beta

2017-11-18 Thread Henning Hraban Ramm
xt/tex/context/base/mkiv/luat-cod.lua:47: bad argument > #1 to 'gmatch' (string expected, got nil) > stack traceback: > [C]: in function 'gmatch' > ...xmf/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:47: in > function 'registercode'

Re: [NTG-context] 'lua.registercode' bug in latest beta

2017-11-06 Thread Henning Hraban Ramm
C]: in function 'gmatch' ...xmf/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:47: in function 'registercode' [ctxlua]:1: in main chunk 20 %C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 %C GNU General Public License for more de

Re: [NTG-context] Sorting of abbreviations in index

2017-10-09 Thread Jano Kula
e. Change definition to: \def\Abk#1{\ctxlua{WriteToIndex("#1")}{\sc\lowercase{#1}}} Add lua code to preamble: \startluacode function WriteToIndex (abbr) -- test, if table exits already if structures.synonyms.collected["abbreviation"] then local abbreviation_entries_table =

Re: [NTG-context] sql / swiglib doesnt find lib

2017-10-02 Thread Michael Eidenbenz
unction 'savedrequire' ...exp/tex/texmf-context/tex/context/base/mkiv/util-lib.lua:246: in function 'require' ...exp/tex/texmf-context/tex/context/base/mkiv/util-sql.lua:114: in function '__index' ...exp/tex/texmf-context/tex/context/bas

Re: [NTG-context] Scite module and escape does not work anymore

2017-08-29 Thread Hans Hagen
[scite] \setuptyping[TEX][escape={[[,]]}] \starttext \startTEX \test[[\em test]] \stopTEX \stoptext The reported error is: [ctxlua]:221: attempt to index local 'specification' (a nil value) stack traceback: [ctxlua]:221: in function <[ctxlua]:220> [C]: in function 'lpegma

[NTG-context] Scite module and escape does not work anymore

2017-08-29 Thread Christoph Reller
\startTEX \test[[\em test]] \stopTEX \stoptext The reported error is: [ctxlua]:221: attempt to index local 'specification' (a nil value) stack traceback: [ctxlua]:221: in function <[ctxlua]:220> [C]: in function 'lpegmatch' ...ext/tex/texmf-context/tex/context/base

Re: [NTG-context] handling code in XML

2017-07-24 Thread Pablo Rodriguez
else > buffers.erase(name) > end > end > > \stopluacode > > \unprotect > > \unexpanded\def\xmlprettyprinttext#1#2% >{\ctxlua{lxml.tobufferX("#1",".","xml-temp")}% > \ifdefined\sci

Re: [NTG-context] handling code in XML

2017-07-24 Thread Hans Hagen
buffers.erase(name) end end \stopluacode \unprotect \unexpanded\def\xmlprettyprinttext#1#2% {\ctxlua{lxml.tobufferX("#1",".","xml-temp")}% \ifdefined\scitebuffer \scitebuffer[#2][xml-temp]% \else \typ

Re: [NTG-context] how to hyphenate SHA512?

2017-07-08 Thread Hans Hagen
3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25% %%7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2 \ctxlua{sha([[8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc257a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2]])} \stoptext *De : *Pablo Rodriguez <mailto:oi..

Re: [NTG-context] how to hyphenate SHA512?

2017-07-08 Thread josephcanedo
cretionary node between each digit using some lua code. There are > mostly likely better solutions for this. > > Joseph > > \startluacode > > function sha(s) >local out = {} >for i = 1, s:len() do > out[#out + 1] = s:sub(i, i) >end >context

Re: [NTG-context] how to hyphenate SHA512?

2017-07-07 Thread Pablo Rodriguez
likely better solutions for this. > > Joseph > > \startluacode > > function sha(s) >local out = {} >for i = 1, s:len() do > out[#out + 1] = s:sub(i, i) >end >context(tab

Re: [NTG-context] how to hyphenate SHA512?

2017-07-07 Thread josephcanedo
) end context(table.concat(out, '\\discretionary{_}{}{}')) end \stopluacode \starttext % \hsize\zeropoint \hyphenation %%8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25% %%7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2 \

Re: [NTG-context] Unicode text conversion

2017-06-15 Thread Procházka Lukáš Ing .
...eta/tex/texmf-context/tex/context/base/mkiv/regi-ini.lua:182: in function 'toregime' [ctxlua]:7: in function 'cvt' [ctxlua]:14: in main chunk 7 local str = io.loaddata(fn) 8 9 str = regimes.toregime("utf", str, "?") 10

Re: [NTG-context] slashes in paths (Lua code)

2017-06-01 Thread Pablo Rodriguez
ha256(name) > local ok = sha("sha256sum",name) > if ok then > context(ok) > end > end > > function document.sha512(name) > local ok = sha("sha512sum",name) > if ok then > contex

Re: [NTG-context] slashes in paths (Lua code)

2017-05-31 Thread Hans Hagen
;sha512sum -b " .. file) context(command_output:sub(0,128)) end \stopluacode \def\shatwo#1% {\ctxlua{document.sha256("#1")}} \def\shafive#1% {\ctxlua{document.sha512("#1")}} \shatwo{Desktop/i-context.pdf} \shafive{i-co

[NTG-context] slashes in paths (Lua code)

2017-05-31 Thread Pablo Rodriguez
ion document.sha256(file) command_output= document.capture("sha256sum -b " .. file) context(command_output:sub(0,64)) end function document.sha512(file) command_output= document.capture("sha512sum -b " .. file) context(command_output:sub(0,1

[NTG-context] getting the glyph of a character

2017-05-01 Thread Jeong Dal
t; > > -- > > Message: 4 > Date: Sun, 30 Apr 2017 21:38:20 +1200 > From: Henri Menke > To: ntg-context@ntg.nl > Subject: [NTG-context] High-level command for translated names > Message-ID: <2e2a759a-25aa-5f58-847d-b66d664ef...@gmail.com> > Con

Re: [NTG-context] High-level command for translated names

2017-04-30 Thread Wolfgang Schuster
ere in lang-txt.lua, but cannot be accessed via \labeltext. One can access them through Lua but that doesn't seem so elegant. \def\chaptername{% \ctxlua{% context(languages.data.labels.texts.chapter.labels["\currentlanguage"])}} \starttext \language[en] \chaptername \lang

[NTG-context] High-level command for translated names

2017-04-30 Thread Henri Menke
them through Lua but that doesn't seem so elegant. \def\chaptername{% \ctxlua{% context(languages.data.labels.texts.chapter.labels["\currentlanguage"])}} \starttext \language[en] \chaptername \language[de] \chaptername \stoptext

Re: [NTG-context] Real number with Lua

2017-04-19 Thread Fabrice Couvreur
2017-04-19 16:04 GMT+02:00 Otared Kavian : > > \starttext > \ctxlua{x = math.floor(10^3*math.pi)/10^3; context(x)} > \stoptext > ​Hi Kavian (or Otared ?), ​Thank you very much, it works. Fabrice ___ I

Re: [NTG-context] Real number with Lua

2017-04-19 Thread Otared Kavian
Hi Fabrice, You can use a construction such as: \starttext \ctxlua{x = math.floor(10^3*math.pi)/10^3; context(x)} \stoptext Best regards: OK > On 19 Apr 2017, at 15:25, Fabrice Couvreur > wrote: > > Hello, > I do not know Lua but I'll learn later. How to display only 3

[NTG-context] Problem loading a DLL with the latest Ctx beta

2017-04-05 Thread Procházka Lukáš Ing .
base/mkiv/l-package.lua:318: in function <...ta/tex/texmf-context/tex/context/base/mkiv/l-package.lua:310> [C]: in function 'requiem' ...ta/tex/texmf-context/tex/context/base/mkiv/l-sandbox.lua:180: in function <...ta/tex/texmf-context/tex/context/base/mkiv/l-sand

Re: [NTG-context] How to use tex.print in ctxlua

2017-03-19 Thread Hans Hagen
On 3/19/2017 4:51 PM, Thomas A. Schmitz wrote: On 19.03.2017 16:30, Otared Kavian wrote: I would like to print in a text the values of a array computed in a \startluacode …. \stopluacode combination. How can I do it properly? Please have a look at the example below and its output, which is not s

Re: [NTG-context] How to use tex.print in ctxlua

2017-03-19 Thread Hans Hagen
On 3/19/2017 5:56 PM, Wolfgang Schuster wrote: Otared Kavian 19. März 2017 um 17:46via Postbox Hi Aditya, Thanks, as Thomas, Pablo and you mentioned the right way is to use context()

Re: [NTG-context] How to use tex.print in ctxlua

2017-03-19 Thread Otared Kavian
Hi Wolfgang, Thanks for letting me know the command string.formatters[….]. It allows to avoid the concatenation, which is to avoid as Thomas points out. Now that I have solved the issue with the spurious space, I have one more question: how could one print the values (vecteuX[i],vecteurY[i]) in

Re: [NTG-context] How to use tex.print in ctxlua

2017-03-19 Thread Wolfgang Schuster
Otared Kavian 19. März 2017 um 17:46via Postbox Hi Aditya, Thanks, as Thomas, Pablo and you mentioned the right way is to use context() instead of tex.print() Actually I just saw

<    1   2   3   4   5   6   7   8   9   10   >