Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread Jairo A. del Rio
project. El dom., 5 de abr. de 2020 a la(s) 09:28, Wolfgang Schuster ( wolfgang.schuster.li...@gmail.com) escribió: > Jairo A. del Rio schrieb am 05.04.2020 um 15:00: > > I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua > > libraries and bindings (defining

Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread Wolfgang Schuster
Jairo A. del Rio schrieb am 05.04.2020 um 15:00: I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua libraries and bindings (defining \ctxlua and the like). For instance, I have the file foo.lua with some macros and I want to use them in my project. Something like

Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread Thomas A. Schmitz
On 05.04.20 15:00, Jairo A. del Rio wrote: I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua libraries and bindings (defining \ctxlua and the like). For instance, I have the file foo.lua with some macros and I want to use them in my project. Something like

Re: [NTG-context] Using Lua files in project structure

2020-04-05 Thread mf
Il 05/04/20 15:00, Jairo A. del Rio ha scritto: I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua libraries and bindings (defining \ctxlua and the like). For instance, I have the file foo.lua with some macros and I want to use them in my project. Something like

[NTG-context] Using Lua files in project structure

2020-04-05 Thread Jairo A. del Rio
I'm writing a project in ConTeXt MKIV and I want to load some (pure) Lua libraries and bindings (defining \ctxlua and the like). For instance, I have the file foo.lua with some macros and I want to use them in my project. Something like this: \startproject project %\component foo.lua %This does

[NTG-context] Solved: Minimum example of problem getting curly braces printed in METAPOST

2020-04-03 Thread Gerben Wierda
ns[+]{doublefun} > > \stopMPinclusions > > \startMPdefinitions{doublefun} > vardef makeTeXLabel( expr w, h, name) = > show "NAME makeTeXLabel:", name; > save p; picture p ; > save s; string s; > s := "\framed{" & name & "}"; % Curly bra

[NTG-context] Minimum example of problem getting curly braces printed in METAPOST

2020-04-02 Thread Gerben Wierda
save p; picture p ;  save s; string s;  s := "\framed{" & name & "}"; % Curly braces will be missing. I need this to work.  % s := "\type-" & name & "-"; % Curly braces are displayed, but this must become a vbox in the end, so can't use it  show "

Re: [NTG-context] Puzzle (for me)

2020-04-01 Thread Gerben Wierda
;> >> Basically, the approach is now something like this: >> >> TeX: calls Lua code with \ctxlua{filename} >> Lua: context.startMPpage >> Lua: read XML. String in XML in filename read by Lua >> Here we know the dimensions in which the string must be typeset and

Re: [NTG-context] Puzzle (for me)

2020-03-31 Thread Henri Menke
; TeX: calls Lua code with \ctxlua{filename} > Lua: context.startMPpage > Lua: read XML. String in XML in filename read by Lua > Here we know the dimensions in which the string must be typeset and wrapped > around because that is also in the XML > Lua: A context() call contains METAPO

[NTG-context] Puzzle (for me)

2020-03-31 Thread Gerben Wierda
I have a string with double quotes that needs to become a text in a box in METAPOST. METAPOST is used to create an image consisting of boxes and connections. Basically, the approach is now something like this: TeX: calls Lua code with \ctxlua{filename} Lua: context.startMPpage Lua: read XML

Re: [NTG-context] conditional for undefined references

2020-03-29 Thread Wolfgang Schuster
Pablo Rodriguez schrieb am 29.03.2020 um 13:53: Dear list, consider the following sample: \setuppapersize[A8] \starttext \ConTeXt: \in[seac] Is it defined?: \doifelse{\in[seac]}{??}{undefined}{defined} \Lua: \ctxlua{context([[{\in[seac

[NTG-context] conditional for undefined references

2020-03-29 Thread Pablo Rodriguez
Dear list, consider the following sample: \setuppapersize[A8] \starttext \ConTeXt: \in[seac] Is it defined?: \doifelse{\in[seac]}{??}{undefined}{defined} \Lua: \ctxlua{context([[{\in[seac]}]])} Is it defined?: \startlua if [[{\in[seac

Re: [NTG-context] Bug (Lua) ?

2020-03-19 Thread Hans Hagen
On 3/19/2020 11:20 AM, Fabrice Couvreur wrote: Hi, this file did not pose any problems but today yes. really? lua error       > lua error on line 34 in file /home/viserion/Table.tex: [ctxlua]:5: unfinished string near '"align={middle,lohi},' there is a "

[NTG-context] Bug (Lua) ?

2020-03-19 Thread Fabrice Couvreur
xt.stopxrow() context.startxrow() for _, letter in ipairs(letters_2) do context.startxcell() context(letter) context.stopxcell() end context.stopxrow() context.startxrow() context.startxcell() context("2") context.stopxcell() context.startxcell({"width=2cm"}) context("Prix (

Re: [NTG-context] Can I share METAPOST vardefs over multiple pages?

2020-03-16 Thread Aditya Mahajan
g setup: \starttext \startMPdefinitions (or inclusions, no difference) % ApplicationComponentLogo is defined here with a vardef \stopMPdefinitions \ctxlua{foo(“filename”)}% produces a series of %context.startMPpage { in

Re: [NTG-context] Can I share METAPOST vardefs over multiple pages?

2020-03-16 Thread Gerben Wierda
tions (or inclusions, no difference) % ApplicationComponentLogo is defined here with a vardef \stopMPdefinitions \ctxlua{foo(“filename”)}% produces a series of %context.startMPpage { instance = "doublefun” }

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

2020-03-11 Thread Hans Hagen
\stopbuffer \startxmlsetups xml:initialize \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

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

2020-03-11 Thread Axel Kielhorn
>> >> 10.I.08 >> >> >> 19 Mar '08 >> >> >> >> >> >> \stopbuffer >> \startxmlsetups xml:initialize >> \xmlsetsetup{#1}{date}{xml:date} &

[NTG-context] Need help processing XML in luacode

2020-03-10 Thread Axel Kielhorn
into a table and write auxiliary functions to access the data and insert them into the TeX output. When I process the included files with context --environment=prozess-style-ecm.tex prozess.xml I get [ctxlua]:19: table index is nil 12 13 doc = xml.load(doclistfile, settings) 14 15

Re: [NTG-context] Accessing raw titles in textcommand in TOC

2020-02-21 Thread alephzorro
; title to my transform function. > > \startluacode > > userdata = userdata or {} > > function userdata.mytransform(title) > > --context(title) --this is just fine, but isn't very useful > > context(string.reverse(title)) > > end > > \stopluacode > > \def\trans

Re: [NTG-context] Accessing raw titles in textcommand in TOC

2020-02-21 Thread alephzorro
textcommand does not work since I can't find the way to pass > > the raw title to my transform function. > > \startluacode > > userdata = userdata or {} > > function userdata.mytransform(title) > >     --context(title) --this is just fine, but isn't very

Re: [NTG-context] Accessing raw titles in textcommand in TOC

2020-02-21 Thread Wolfgang Schuster
context(title) --this is just fine, but isn't very useful > context(string.reverse(title)) > end > \stopluacode > > \def\transformtitle#1% > {\ctxlua{userdata.mytransform([==[#1]==])}} > > \setuplist[chapter][textcommand=\transformtitle] > > \starttext &

Re: [NTG-context] Accessing raw titles in textcommand in TOC

2020-02-21 Thread Hans Hagen
ata or {} function userdata.mytransform(title)     --context(title) --this is just fine, but isn't very useful     context(string.reverse(title)) end \stopluacode \def\transformtitle#1%     {\ctxlua{userdata.mytransform([==[#1]==])}} \setuplist[chapter][textcommand=\transformtitle] \startt

[NTG-context] Accessing raw titles in textcommand in TOC

2020-02-21 Thread alephzorro
tle#1% {\ctxlua{userdata.mytransform([==[#1]==])}} \setuplist[chapter][textcommand=\transformtitle] \starttext \completecontent \startchapter[title={Sample Chapter}] \stopchapter \stoptext When I print the actual title that is passed to mytransform, all I get is \currentlistentrytitle an

Re: [NTG-context] Label in externalfigures

2020-02-14 Thread Jan-Erik Hägglöf
ncluding label stuffwhat you can also try (with lmtx) is this (no real interface yet):\starttext\hbox\bgroup  \ctxlua{metapost.startsvghashing()}%  \includesvgfile[labels-004.svg]%  \ctxlua{metapost.stopsvghashing()}%\egroup\stoptextwhich should turn your labels into tex, so you can typeset them as tex (so $

Re: [NTG-context] Label in externalfigures

2020-02-13 Thread Jan-Erik Hägglöf
investigate the details manual tip you provided, thanks a lot. > you might want to peek into the luametafun manual as svg is discussed there, > including label stuff > > what you can also try (with lmtx) is this (no real interface yet): > > \starttext > > \hbox\bgroup &

Re: [NTG-context] Label in externalfigures

2020-02-12 Thread Hans Hagen
there, including label stuff what you can also try (with lmtx) is this (no real interface yet): \starttext \hbox\bgroup \ctxlua{metapost.startsvghashing()}% \includesvgfile[labels-004.svg]% \ctxlua{metapost.stopsvghashing()}% \egroup \stoptext which should turn your labels into tex, so you can

Re: [NTG-context] repeat a page inside a document

2020-02-07 Thread Pablo Rodriguez
ter my previous message is that both "\savebuffer[whatever][αβδ.γεζ]" and "\ctxlua{os.remove([[\jobname]].."-αβδ.γεζ")}" are portable ways of creating and removing empty files. > Another way is to use a make file (or a ctx-file for ConTeXt) > to add a image

Re: [NTG-context] "error not related to input file"

2019-12-16 Thread Rudolf Bahr
kens.getters.macro("projectpath") local xO = tokens.getters.macro("xO") local yO = tokens.getters.macro("yO") local I = {} -- Table of initial values I ["projectpath"] = ppth I ["column"] = {} I ["colum

Re: [NTG-context] ConTeXt: specify a path to font in \definefontfamily

2019-11-20 Thread Krešimir Cindrić
s normally a bad idea to have fonts in such a place. You never know > how it will clash with other fonts (versions, similar names, etc). > > In context, we have > > tex/texmf-fonts > > so best is to use: > > tex/texmf-fonts/data/MyFont-It.otf > > etc,

Re: [NTG-context] ConTeXt: specify a path to font in \definefontfamily

2019-11-20 Thread Hans Hagen
environment variable. Like: \starttext % \ctxlua{fonts.names.addruntimepath("./myfonts")} \ctxlua{os.setenv("RUNTIMEFONTS","./myfonts")} Hello World! \definefont[myfont][file:myfont.otf] {\myfont Hello World!} \stoptext But .. you need tio wipe such

[NTG-context] Luacode: Data File to Table

2019-10-24 Thread Rudolf Bahr
ture_name, [ "width_px" ] = b.width_px, [ "height_px" ]= b.height_px, } context ( 'function Rosi(): b.smrk = ', b.smrk ) context.par()

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-16 Thread Rudolf Bahr
andalone lua typically sees only one chunk (the file you pass on the > > command > > line) but embedded lua implementation often see (sometimes many) more > > chunks. > > In luatex’s case, each \directlua is a separate chunk (in ConTeXt, that > > means every > > \s

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-15 Thread Hans Hagen
(sometimes many) more chunks. In luatex’s case, each \directlua is a separate chunk (in ConTeXt, that means every \startluacode block and every \ctxlua call is a separate chunk). The only unusual thing here is that standalone lua silently quits and returns a non-zero exit code to the shell, wher

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-15 Thread Taco Hoekwater
many) more chunks. In luatex’s case, each \directlua is a separate chunk (in ConTeXt, that means every \startluacode block and every \ctxlua call is a separate chunk). The only unusual thing here is that standalone lua silently quits and returns a non-zero exit code to the shell, whereas luatex

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-14 Thread Rudolf Bahr
On Mon, Oct 14, 2019 at 09:26:58PM +0200, Taco Hoekwater wrote: > Hi, > > > On 14 Oct 2019, at 21:08, Rudolf Bahr wrote: > > > > > > 2. But in the case of an not existing file (BBB.lua) the known error > > message comes up > > again: > > &qu

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-14 Thread Taco Hoekwater
Hi, > On 14 Oct 2019, at 21:08, Rudolf Bahr wrote: > > > 2. But in the case of an not existing file (BBB.lua) the known error message > comes up > again: > "token call, execute: [ctxlua]:8: /home/sam/context-tests/BBB.lua: No such > file or >directory

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-14 Thread Rudolf Bahr
>context ( " exists!" ) > > else > >context ( name ) > > context ( " doesn't exist!" ) > > end > > end > > > > \stopluacode > > > > > > \starttext > > > > \def\l

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-14 Thread Hans Hagen
( name, "r" )) if f then f:close () context ( name ) context ( " exists!" ) else context ( name ) context ( " doesn't exist!" ) end end \stopluacode \starttext \def\lookupfile#1% {\ctxl

Re: [NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-14 Thread Taco Hoekwater
Hi, > On 14 Oct 2019, at 18:51, Rudolf Bahr wrote: > >  > Dear List! > > THis MWE must be faulty, but where is the error? > > === > \lookupfile{"$HOME/context-tests/AAA.lua"}% "AAA.lua" intentionally does > exist $HOME is an actual

[NTG-context] RE : \ctxlua and \startluacode ... \stopluacode

2019-10-14 Thread Joseph
I suspect the double quotes are part of file names, hence files cannot be found. Perhaps try remove them in macro argument. Hope this helps De : Rudolf Bahr Envoyé le :lundi 14 octobre 2019 18:50 À : ntg-context@ntg.nl Objet :[NTG-context] \ctxlua and \startluacode ... \stopluacode Dear List

[NTG-context] \ctxlua and \startluacode ... \stopluacode

2019-10-14 Thread Rudolf Bahr
f:close () context ( name ) context ( " exists!" ) else context ( name ) context ( " doesn't exist!" ) end end \stopluacode \starttext \def\lookupfile#1% {\ctxlua{userdata.file_exists([==[#1]==])}} \lookupfile{"$HOME/cont

Re: [NTG-context] List of Symbols/Abbreviations/Glosses with more then two entries

2019-10-11 Thread Thomas Welter
t;-comparator to compare the keys a and b printlistitem(keyword, values) end context.TB{"2ex"} for keyword, values in userdata.sorttable(latingroup, function(t,a,b) return string.lower(a) < string.lower(b) end) do printlistitem(keyword, values) end context.stoptabulate() end \stopluacode

Re: [NTG-context] passing variables/data between context and lua

2019-09-27 Thread mf
ta.points = tonumber( question ) * 92 -- do some calculations with points and return to to context userdata.answer=42 \stopluacode % lots of Text in between The answer is \ctxlua{ context(userdata.answer) }. Points are \ctxlua{ context(userdata.points) }. \stoptext Best wishes, Massi Il 27

[NTG-context] Extracting a column from an array in lua

2019-09-20 Thread Otared Kavian
t[i]["columnTwo"] = 10*i + 2 end tt = {} for i = 1,3 do -- is it possible to avoid this ? tt[i] = t[i]["columnOne"] end \stopluacode The first column of the array \type{t} is: \ctxlua{context.print(tt," ; ")} \

[NTG-context] expansion problem: random location

2019-09-13 Thread Henning Hraban Ramm
\fakewords{3}{20}}] \externalfigure[place #1][width=\PicWidth,height=\dimexpr\textheight * \imgH / 10 \relax] \stopplacefigure } \starttext \dorecurse{3} {\chapter{\fakewords{5}{10}} \dorecurse{3} {\dorecurse{3}{\fakewords{50}{100}\endgraf} \Blindbild{\ctxlua

Re: [NTG-context] Cross-reference expansion with ConTeXt and processing with LuaTeX

2019-09-06 Thread Oliver von Criegern
tupreferencing[state=start] \definenumber[test] \setnumber[test][5] \startluacode function TestVarA(var)     print('VARIABLE A: ',var)     context(var) end function TestVarB(var)     print('VARIABLE B: ',var)     context.inlinerange { var } end \stopluacode \def\TestLuaA#1{\ctxlua{TestVarA(#

Re: [NTG-context] Cross-reference expansion with ConTeXt and processing with LuaTeX

2019-09-05 Thread Hans Hagen
are obviously not being expanded before they are passed to Lua. Here is a minimal example: |\setupreferencing[state=start]||\definenumber[test]\setnumber[test][5]\startluacodefunction TestVar(var)print('VARIABLE: ')print(var)tex.print(var)end \stopluacode\def\TestLua#1{\ctxlua{TestVar([==[#1]==])}}% Cf

[NTG-context] Cross-reference expansion with ConTeXt and processing with LuaTeX

2019-09-04 Thread Oliver von Criegern
to Lua. Here is a minimal example: |\setupreferencing[state=start]||\definenumber[test]\setnumber[test][5]\startluacodefunction TestVar(var)print('VARIABLE: ')print(var)tex.print(var)end \stopluacode\def\TestLua#1{\ctxlua{TestVar([==[#1]==])}}% Cf. https://www.contextgarden.net

Re: [NTG-context] Bug with jobs.file.run?

2019-08-25 Thread Aditya Mahajan
] \starttext \startbuffer[test] print("Output from lua") \stopbuffer \savebuffer[list={test}, file={test.lua}, prefix=no] \ctxlua{job.files.run("test.lua", "lua test.lua > test-output.tex")} \ReadFile{test-output.tex} \savebuffer[list={test

[NTG-context] Issue with \hbox attrSomeAttr=Val (LTMX only)

2019-07-19 Thread Joseph Canedo
= nuts.takebox(box_id) local margin_node = nuts.getattr(box, margin_node_attr) context('Expected 555=' .. (margin_node or '(nil)')) end \stopluacode \starttext Test. \the\MarginNodeattribute \setbox\MyBox\hbox attr\the\MarginNodeattribute=555{Test} \ctxlua{test_attribute(\the\MyBox

Re: [NTG-context] an object representation of the node list of a paragraph: a lua table or a JSON

2019-07-10 Thread Hans Hagen
r the list of nodes of a paragraph, figuring out all the possible nodes and their fields, i'm wondering if there's some hidden tool in the ConTeXt coffer to simplify the task. \starttext \setbox0\vbox{\input tufte } \ctxlua{inspect(nodes.totable(tex.box[0]))} \stoptext \starttext \se

Re: [NTG-context] Fwd: [garden] debug getinfo error

2019-07-10 Thread Hans Hagen
 > latin modern fonts are not preloaded languages   > language 'en' is active open source > level 2, order 3, name '/tmp/uhd8RE/texweb.tex' fonts   > preloading latin modern fonts (second stage) fonts   > 'fallback modern-designsize rm 12pt' is loaded lua error

[NTG-context] Fwd: [garden] debug getinfo error

2019-07-10 Thread Taco Hoekwater
> files > jobname 'texweb', input './texweb', result 'texweb' > fonts > latin modern fonts are not preloaded > languages > language 'en' is active > open source > level 2, order 3, name '/tmp/uhd8RE/texweb.tex' > fonts > preloading latin modern

Re: [NTG-context] interfaces.definecommand fails with brackets inside string arguments

2019-07-09 Thread Hans Hagen
ds defined by interfaces.definecommand fail when you pass string arguments that contain brackets. I think cldf-int.lua needs a patch to support those kind of arguments. FYI, it fails because definecommand() creates a \myCommand that is equivalent to this: \def\myCommand#1{\ctxlua {_clmm_('myCom

Re: [NTG-context] interfaces.definecommand fails with brackets inside string arguments

2019-07-09 Thread Taco Hoekwater
necommand fail when you > pass string arguments that contain brackets. > > I think cldf-int.lua needs a patch to support those kind of arguments. FYI, it fails because definecommand() creates a \myCommand that is equivalent to this: \def\myCommand#1{\ctxlua {_clmm_('myCommand',[[

Re: [NTG-context] newlines in return Lua string

2019-06-15 Thread Aditya Mahajan
On Sat, 15 Jun 2019, Hans van der Meer wrote: From\ctxlua{tex.print(hvdm.myluacall("\xmlatt{#1}{argument}"))} Lua returns a string containing newline characters '\n'. In ConTeXt this returned string is printed as one line, the embedded newlines are not honoured. I thought

[NTG-context] newlines in return Lua string

2019-06-15 Thread Hans van der Meer
From\ctxlua{tex.print(hvdm.myluacall("\xmlatt{#1}{argument}"))} Lua returns a string containing newline characters '\n'. In ConTeXt this returned string is printed as one line, the embedded newlines are not honoured. I thought to replace with \crlf in this manner: string1

Re: [NTG-context] tex.month can't be overridden like tex.day and tex.year

2019-05-06 Thread Hans Hagen
On 5/2/2019 5:54 PM, Tristan Stenner wrote: Dear list, in the following document I can set the date as seen by LuaTeX so the date functions use a different date: --- \starttext \ctxlua{tex.year=1980; tex.month=1; tex.day=15} % Taken from https://wiki.contextgarden.net/Command/date, % outputs

[NTG-context] tex.month can't be overridden like tex.day and tex.year

2019-05-03 Thread Tristan Stenner
Dear list, in the following document I can set the date as seen by LuaTeX so the date functions use a different date: --- \starttext \ctxlua{tex.year=1980; tex.month=1; tex.day=15} % Taken from https://wiki.contextgarden.net/Command/date, % outputs 15 may 1980 \date[m=1][day,~,{\monthshort

[NTG-context] Strange backgroundcolors with showgrid and luacode

2019-04-26 Thread Otared Kavian
quot;=") context.NR() end context.stoptabulate() context.stopcolumns() context.page() end \stopluacode \starttext \ctxlua{AdditionTest(12)} % the background colors, gray and blue, show up when a lua function is called % \ctxlua{AdditionTest(120)}

Re: [NTG-context] single command for \ctxlua{context(...)}

2019-03-12 Thread Pablo Rodriguez
On 3/11/19 10:36 PM, Wolfgang Schuster wrote: > Pablo Rodriguez schrieb am 11.03.19 um 22:23: >> [...] >> Is there a single command for \ctxlua{context(...)}? > > \cldcontext{...} Many thanks for your fast reply, Wolfgang. Pablo --

Re: [NTG-context] single command for \ctxlua{context(...)}

2019-03-11 Thread Wolfgang Schuster
Pablo Rodriguez schrieb am 11.03.19 um 22:23: Dear list, I know this has been already posted to the list, but I cannot find it right now. Is there a single command for \ctxlua{context(...)}? \cldcontext{...} Wolfgang

[NTG-context] single command for \ctxlua{context(...)}

2019-03-11 Thread Pablo Rodriguez
Dear list, I know this has been already posted to the list, but I cannot find it right now. Is there a single command for \ctxlua{context(...)}? Many thanks for your help, Pablo -- http://www.ousia.tk ___ If your

[NTG-context] util-sha.lua misbehaving?

2019-02-28 Thread Pablo Rodriguez
(s, '%s+$', '') s = string.gsub(s, '[\n\r]+', ' ') return s end function document.sha512(file) command_output= document.capture("sha512sum -b " .. file) context(command_output:sub(0,8)) end \stopluacode \def\shafive#1{\ctxlua{document.

Re: [NTG-context] Omitting part number in chapter numbers

2019-02-20 Thread Wolfgang Schuster
the length (seems to be 19 at least for me) works just fine as well as printing the string itself to the document. \startluacode userdata = userdata or{} function userdata.numberfun(str)     context(tostring(#str)) end \stopluacode \def\mync#1% {\ctxlua{userdata

[NTG-context] Omitting part number in chapter numbers

2019-02-19 Thread Simon Collier
ne as well as printing the string itself to the document. \startluacode userdata = userdata or { } function userdata.numberfun ( str ) context ( tostring(#str) ) end \stopluacode \def \mync #1 % { \ctxlua { userdata.numberfun ( [ == [ #1 ] == ] ) } } The i

Re: [NTG-context] Macro for a header does not work as well

2019-02-19 Thread Otared Kavian
from last year this showed the right date format, > now it shows: d=1m=3y=2019 > > > > \def\duedate{\ctxlua{ > local t = os.date('*t', os.time()+ 10 * 24 * 3600) > context.date{d=t.day, m=t.month, y=t.year

Re: [NTG-context] Macro for a header does not work as well

2019-02-19 Thread Jan U. Hasecke
es not solve the problem. In a context version from last year this showed the right date format, now it shows: d=1m=3y=2019 #### \def\duedate{\ctxlua{ local t = os.date('*t', os.time()+ 10 * 24 * 3600) context.date{d=t.day, m=t.month, y=t.year } }} \mainlanguage[de] \starttext \

Re: [NTG-context] Define color with calculations

2019-02-18 Thread Mohammad Hossein Bateni
Thanks, Henri! Works like a charm. On Sun, Feb 17, 2019 at 11:03 PM Henri Menke wrote: > Use Lua. > > > \def\eval#1{\ctxlua{% > local context = context > local _ENV = math > context(#1) > }} > > \definecolor[mycolor][r=\eval{0.5*0.7}] > >

Re: [NTG-context] Define color with calculations

2019-02-17 Thread Henri Menke
Use Lua. \def\eval#1{\ctxlua{% local context = context local _ENV = math context(#1) }} \definecolor[mycolor][r=\eval{0.5*0.7}] \starttext \color[mycolor]{Hello!} \stoptext On 18/02/19 4:37 PM, Mohammad Hossein Bateni wrote: > Hi, > > When I use definecolor, (how)

Re: [NTG-context] How to query fonts.handlers

2019-02-05 Thread Henri Menke
I found a solution. \startluacode fonts.handlers.otf.addfeature { name = "ktest", type = "kern", data = { ["t"] = { ["e"] = 500 }, } } \stopluacode \definefontfeature[ktest][ktest=yes] \definefont[1][Serif*ktest] \st

[NTG-context] How to query fonts.handlers

2019-02-05 Thread Henri Menke
? Cheers, Henri --- \startluacode fonts.handlers.otf.addfeature { name = "ktest", type = "kern", data = { ["t"] = { ["e"] = 500 }, } } \stopluacode \definefontfeature[ktest][ktest=yes] \definefont[1][Serif*ktest] \starttext \1 tes

Re: [NTG-context] getting ConTeXt results back to Lua (for typesetting solutions at end of document)

2019-01-31 Thread Weber, Matthias
he end (with the "1.1" >> remembered from when the problem was typeset): >> Solution to Problem 1.1. >> An answer >> It seems that buffers are the way to do this. But I cannot quite get >> the automatic numbering to work. The delayed evaluation and informa

Re: [NTG-context] getting ConTeXt results back to Lua (for typesetting solutions at end of document)

2019-01-31 Thread Wolfgang Schuster
ng to work. The delayed evaluation and information passing between lua and ConTeXt has me confused and tangled in a knot. Below is a minimal almost-working example. The issue is in the line {\ctxlua{userdata.addTempToBuffer('#1', [==[\getnumber[problem]]==])}} which ends up putting the verba

[NTG-context] getting ConTeXt results back to Lua (for typesetting solutions at end of document)

2019-01-31 Thread Sanjoy Mahajan
ng to work. The delayed evaluation and information passing between lua and ConTeXt has me confused and tangled in a knot. Below is a minimal almost-working example. The issue is in the line {\ctxlua{userdata.addTempToBuffer('#1', [==[\getnumber[problem]]==])}} which ends up putting the verba

Re: [NTG-context] Sorting registers method for "uppercase like lowercase, diacritics ignored"

2019-01-20 Thread Thomas A. Schmitz
ta or { } function userdata.indexing(s) t = characters.lower(characters.shaped(s)) context.nome( { t }, s) end \stopluacode \def\mynome#1% {\ctxlua{userdata.indexing([==[#1]==])}} \starttext \mynome{árvore}árvore \mynome{Äard}Äard \mynome{água}água \mynome{Água}Água \mynome{abnegação}abneg

Re: [NTG-context] Scaling down symbols and emojis

2019-01-19 Thread User 19087
vement? % A '\start...\stopluacode' block inside a macro is just as bad (or worse?) to % escape as '\ctxlua' code. So create a function here for use elsewhere. % % There were multiple font sizes in the "specification" and "parameters" % tables, hopefully I picked the r

Re: [NTG-context] Get list of all buffer names from lua

2019-01-08 Thread Hans Hagen
return {ex1, ex2} or similar \ctxlua{context(...)} \stoptext The underlying idea is to store a large number of example problems in individual buffers that could be retrieved either by specific name or as a complete list. I'm having a problem with the latter as it seems like all the lua buffer

Re: [NTG-context] Get list of all buffer names from lua

2019-01-07 Thread Stanislav Sokolenko
ocal names = {} for name,_ in pairs(cache) do     names[#names+1] = name end context(table.concat(names,", ")) \stopluacode \stoptext \starttext \startbuffer[ex1] Buffer 1 \stopbuffer \startbuffer[ex2] Buffer 2 \stopbuffer % Should return {ex1, ex2} or similar \ctxlua{context(...)} \stoptext

Re: [NTG-context] Get list of all buffer names from lua

2019-01-07 Thread Henri Menke
r[ex1] > Buffer 1 > \stopbuffer > \startbuffer[ex2] > Buffer 2 > \stopbuffer > % Should return {ex1, ex2} or similar > \ctxlua{context(...)} > \stoptext > > The underlying idea is to store a large number of example problems in > individual buffers that could be retri

[NTG-context] Get list of all buffer names from lua

2019-01-07 Thread Stanislav Sokolenko
Dear list, As the subject line states, I am looking for a means of retrieving a table of all saved buffer names from lua. A MNWE would looks like: \starttext \startbuffer[ex1] Buffer 1 \stopbuffer \startbuffer[ex2] Buffer 2 \stopbuffer % Should return {ex1, ex2} or similar \ctxlua{context

Re: [NTG-context] searching in nodes

2018-12-17 Thread Hans Hagen
\def\findmypattern#1#2{\ctxlua{tex.print(hvdm.findmypattern("#1","#2",))} But I do not seem to get the node contents in the first argument #1. Using \xmlverbatim{#1} fails with Lua error "hexadecimal digit expected near '"\xm’”. \xmlflushpure{#1} fails with Lua error &qu

Re: [NTG-context] Drops Module

2018-12-13 Thread Peter Rolf
ber has no integer representation) > stack traceback: >     [C]: in function 'string.format' >     /home/adityam/texmf/tex/context/third/drops/t-drops.lua:1098: in > upvalue 'get_IM_paths' >     /home/adityam/texmf/tex/context/third/drops/t-drops.lua:1380: in > field 'sha

[NTG-context] searching in nodes

2018-12-12 Thread Hans van der Meer
In a Lua function called from within an \startxmlsetups..\stopxmlsetups code block I would like to search through the current node and all below. Using string.match("to-be-searched”,”pattern”). The Lua function being called through \def\findmypattern#1#2{\ctxlua{tex.print(hvdm.findmypatter

[NTG-context] Drops Module

2018-12-10 Thread Aditya Mahajan
/tex/context/third/drops/t-drops.lua:1098: in upvalue 'get_IM_paths' /home/adityam/texmf/tex/context/third/drops/t-drops.lua:1380: in field 'shadow' [ctxlua]:1: in main chunk This is due to the change in Lua5.3 with respect to floating point numbers. The simplest solution is to change '%d

Re: [NTG-context] directlua question

2018-12-04 Thread Wolfgang Schuster
finished string near eof”. Obviously caused by the %’s. How to get this working? \textpercent will not do, off course within Luacode. % = \letterpercent $ = \letterdollar You can also replace \directlua{tex.print(...)} with \ctxlua{context(...)} or \cldcontext

Re: [NTG-context] Grammar to parse TeX input?

2018-11-27 Thread Joseph Canedo
xpanded ? > > end > > \stopluacode > > \definebuffer[ZZZBuffer] > > \def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]} > > \def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}} > > \StartZZZ > > \

Re: [NTG-context] Grammar to parse TeX input?

2018-11-26 Thread Hans Hagen
\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}} \StartZZZ \input knuth \StopZZZ context.processbuffer { "ZZZBuffer" } - Hans Hagen | PRAGMA ADE Ridde

[NTG-context] Grammar to parse TeX input?

2018-11-26 Thread Joseph Canedo
function zzz_function(text) - How to process ‘text’ to get bits which are macros, groups etc… ? Eventually expanded ? end \stopluacode \definebuffer[ZZZBuffer] \def\StartZZZ{\grabbufferdata[ZZZBuffer][StartZZZ][StopZZZ]} \def\StopZZZ{\ctxlua{zzz_function(buffers.getcontent('ZZZBuffer'))}} \StartZZZ

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

2018-10-09 Thread Alan Braslau
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]% \ctxlua{userdat

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

2018-10-08 Thread Aditya Mahajan
ourPlot[#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{doublefun::C

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
il calls...) ...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:114: in function '__index' ...xlive/2017/texmf-dist/tex/context/base/mkiv/util-sql.lua:288: in function 'execute' [ctxlua]:38: in ma

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

2018-10-01 Thread Ulrike Fischer
here 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 > }} > &

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
  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 .. "[];")     tex.print(char .. &qu

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

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

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

2018-09-22 Thread Hans Hagen
.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{     local char = "\luaescapestring{

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