[NTG-context] \getdocumentfilename or document.files

2024-02-27 Thread Pablo Rodriguez via ntg-context
Dear list, I have the following sample (saved as "a.tex"): \starttext \getdocumentfilename{1} \cldcontext{document.files[1]} \getdocumentfilename{2} \cldcontext{document.files[2]} \getdocumentfilename{3} \cldcontext{document.files[3]} \stoptext I compile it with:

[NTG-context] XML processing, unwanted indentation/alignment

2024-02-15 Thread Michael Guravage
number into a tel:link - without spaces \def\phonelink#1% {\goto{#1} [url(tel:\cldcontext{string.nospaces("#1")})]} % Derive an individual's name \def\name#1% {\ifxmlattempty{#1}{first_name} {\xmlatt{#1}{initials}} \else {\xmlatt{#1}{initials}, \xmlatt{#1}{first_name}} \fi \ifxmla

[NTG-context] Re: removing whitespace

2024-02-13 Thread Wolfgang Schuster
)})]   } ConTeXt has a Lua function to remove spaces. \starttext \cldcontext{string.nospaces("01234 56789")} \stoptext Wolfgang ___ If your question is of interest to others as well, please add an ent

Re: [NTG-context] numbering questions

2022-12-31 Thread Henning Hraban Ramm via ntg-context
. \startluacode function document.leadingzeros(str) local lzeros = 3-str:len() return ("0"):rep(lzeros) end \stopluacode \unexpanded\def\lzeros#1% {\cldcontext{document.leadingzeros("#1")}} Same. With numbercommand, Lua gets "\s and can’t handle it

Re: [NTG-context] numbering questions

2022-12-31 Thread Pablo Rodriguez via ntg-context
t.leadingzeros(str) local lzeros = 3-str:len() return ("0"):rep(lzeros) end \stopluacode \unexpanded\def\lzeros#1% {\cldcontext{document.leadingzeros("#1")}} > * I can force a section number with “ownnumber”, but the next one is > back in the previous

Re: [NTG-context] How to display the pages of a particular section in another PDF?

2022-12-05 Thread Hans Hagen via ntg-context
ore inpiut and discussion for that \starttexdefinition DoWithSection #1#2 \startpagemakeup \externalfigure[#1.pdf][page=#2] \stoppagemakeup \stoptexdefinition \starttexdefinition LoadSectionsA #1#2 \ctxlua{document.loadsection("#1","#2")} \doifnot{\cldcontext{do

Re: [NTG-context] new hash for buffer (as file)

2022-09-25 Thread Pablo Rodriguez via ntg-context
uot;) function sha256(str) if os.name == "windows" then return utilities.sha2.hash256(str:gsub("\r", "\r\n")) else return utilities.sha2.hash256(str:gsub("\r", "\n")) end end \stopluacode \def\shabuffer#1% {\cldcont

Re: [NTG-context] new hash for buffer (as file)

2022-09-22 Thread Max Chernoff via ntg-context
and another one \stopbuffer \starttext \startluacode require("util-sha") function sha256(str) return utilities.sha2.hash256( str:gsub(string.char(0x0D), string.char(0x0A)) ) end \stopluacode \def\shabuffer#

[NTG-context] new hash for buffer (as file)

2022-09-22 Thread Pablo Rodriguez via ntg-context
habuffer#1% {\cldcontext{utilities.sha2.hash256(buffers.raw("#1"))}} \def\shafile#1% {\cldcontext{utilities.sha2.hash256(io.loaddata("#1"))}} \def\shabufferfile#1% {\cldcontext{utilities.sha2.hash256(buffers.raw("#1"))}} \shabuffer{test} \savebuffer[tes

Re: [NTG-context] hash for buffer contents

2022-09-22 Thread Pablo Rodriguez via ntg-context
est \stopbuffer \starttext \startluacode require("util-sha") function document.sha512buffer(buffer) return utilities.sha2.hash512(buffers.raw(buffer)) end \stopluacode \def\shabuffer#1 {\cldcontext{document.sha512buffer("#1")}} \shabuff

[NTG-context] hash for buffer contents

2022-09-21 Thread Pablo Rodriguez via ntg-context
Dear list, I have the following sample: \ctxlua{require("util-sha")} \starttext \startbuffer[abc] samples \stopbuffer \cldcontext{utilities.sha2.hash512("buffer-name")} \stoptext Is there any way to get "utilities.sha2.hash512" with the conte

Re: [NTG-context] SHA calculation

2022-08-28 Thread Pablo Rodriguez via ntg-context
ontext > garden.  > Where to look? Dear dr. van der Meer, it is my fault since Hans explained this before (to me). Here you have the minimal sample: \ctxlua{require("util-sha")} \def\shatwo#1{% \cldcontext{utilities.sha2.hash256("#1")}} \def\shafive#1{%

Re: [NTG-context] Foonotes in Captions ... again

2022-06-16 Thread Denis Maier via ntg-context
userdata.save_data[#1] = userdata.visual_order > > }% > > } > > > > \let\old_footnote=\footnote > > > > \starttexdefinition protected footnote #1 > > \begingroup > > \clf_set_footnote_number > > >

Re: [NTG-context] Foonotes in Captions ... again

2022-06-16 Thread Denis Maier via ntg-context
userdata.visual_order = userdata.visual_order + 1 > userdata.save_data[#1] = userdata.visual_order > }% > } > > \let\old_footnote=\footnote > > \starttexdefinition protected footnote #1 > \begingroup > \clf_set_footnote_

Re: [NTG-context] Foonotes in Captions ... again

2022-06-15 Thread Max Chernoff via ntg-context
\def\insert##1\bgroup##2\egroup{ \normalexpanded{ \noexpand\save_footnote_data {\cldcontext{userdata.input_order}} } \normalinsert##1{##2} } \old_footnote{#1} \endgroup \stoptexdefiniti

Re: [NTG-context] Changing font and font size inside textex

2022-05-30 Thread Stefan Nedeljkovic via ntg-context
setxheight [#1][#2] > > \switchtobodyfont[#1, 12pt] > > \scratchdimen=\dimexpr#2\relax > > \switchtobodyfont[#1, \cldcontext{tex.dimen.scratchdimen / > tex.sp"1ex" > > * tex.sp"1em" .. "sp"}] > > \stoptexdefinition > > > > But I can't

Re: [NTG-context] Changing font and font size inside textex

2022-05-30 Thread Max Chernoff via ntg-context
I'm using the following macro to set the font size via h-height: \starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \scratchdimen=\dimexpr#2\relax \switchtobodyfont[#1, \cldcontext{tex.dimen.scratchdimen / tex.sp"1ex" * tex.sp"1em" .. "sp&quo

[NTG-context] Changing font and font size inside textex

2022-05-30 Thread Stefan Nedeljkovic via ntg-context
[#1, 12pt] \scratchdimen=\dimexpr#2\relax \switchtobodyfont[#1, \cldcontext{tex.dimen.scratchdimen / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition But I can't figure out how to use that in MPpage. Any help would be a

Re: [NTG-context] Specifying font size as x-height

2022-05-28 Thread Stefan Nedeljkovic via ntg-context
old version expected direct input, not a \dimen. Try this: > > \starttexdefinition setxheight [#1][#2] > \switchtobodyfont[#1, 12pt] > \scratchdimen=\dimexpr#2\relax > \switchtobodyfont[#1, \cldcontext{tex.dimen.scratchdimen / > tex.sp"1ex"

Re: [NTG-context] Specifying font size as x-height

2022-05-28 Thread Max Chernoff via ntg-context
] \switchtobodyfont[#1, 12pt] \scratchdimen=\dimexpr#2\relax \switchtobodyfont[#1, \cldcontext{tex.dimen.scratchdimen / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition \definemeasure[xheight][2.5pt] \starttext \setxheight[advento

Re: [NTG-context] Specifying font size as x-height

2022-05-28 Thread Stefan Nedeljkovic via ntg-context
How would one specify the font size in LMTX, but via x-height? >> >> You could try this: >> >> \starttexdefinition setxheight [#1][#2] >> \switchtobodyfont[#1, 12pt] >> \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp&qu

Re: [NTG-context] Specifying font size as x-height

2022-05-28 Thread Stefan Nedeljkovic via ntg-context
\switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * > tex.sp"1em" .. "sp"}] > \stoptexdefinition > > Demo: > > \starttexdefinition setxheight [#1][#2] > \switchtobodyfont[#1, 12pt] >

Re: [NTG-context] Specifying font size as x-height

2022-05-28 Thread Max Chernoff via ntg-context
How would one specify the font size in LMTX, but via x-height? You could try this: \starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * tex.sp"1em" .. "

Re: [NTG-context] read PDF metadata from other file

2021-09-11 Thread Hans Hagen via ntg-context
On 9/11/2021 2:35 PM, Pablo Rodriguez via ntg-context wrote: Dear list, I have the following sample: \starttext \setupinteraction [state=start, title={\cldcontext{pdfe.open("b.pdf").Info.Title}}] \null \stoptext From a document composed with \insertpag

[NTG-context] read PDF metadata from other file

2021-09-11 Thread Pablo Rodriguez via ntg-context
Dear list, I have the following sample: \starttext \setupinteraction [state=start, title={\cldcontext{pdfe.open("b.pdf").Info.Title}}] \null \stoptext From a document composed with \insertpages, I need to transfer medatada. But I get the raw value "feff0061&

[NTG-context] new upload

2021-08-24 Thread Hans Hagen via ntg-context
) \starttext % \enabletrackers[system.randomizer.details] % empty == default \newrepeatablerandom\MyRandom {Welcome 2 America} \newrepeatablerandom\MyRandomN{\randomnumber{0}{1000}} \newrepeatablerandom\MyRandomM{\randomnumber{0}{1000}} \cldcontext

Re: [NTG-context] lpeg pattern in function

2021-08-07 Thread Marcus Vinicius Mesquita via ntg-context
t; > when the word contains the letters ó or ô. > > We get zoolco instead of zoológico, and termtro instead of termômetro. > > What am I doing wrong? > > > > mwe: > > > > \def\stripnumber#1% > > {\cldcontext{lpeg.match(lpeg.stripper("[¹²³⁴

Re: [NTG-context] lpeg pattern in function

2021-08-07 Thread Hans Hagen via ntg-context
: \def\stripnumber#1%         {\cldcontext{lpeg.match(lpeg.stripper("[¹²³⁴⁵⁶⁷⁸⁹⁰]"), [==[#1]==])}} \starttext \stripnumber{árbitro⁶} \stripnumber{ébano¹} \stripnumber{ícone⁸} \stripnumber{zoológico⁰} \stripnumber{eletroacústico⁹} \stripnumber{trânsfuga⁷} \stripnumber{fa

[NTG-context] lpeg pattern in function

2021-08-06 Thread Marcus Vinicius Mesquita via ntg-context
Dear list, in the mwe below, the expected result is ok for most entries but fails when the word contains the letters ó or ô. We get zoolco instead of zoológico, and termtro instead of termômetro. What am I doing wrong? mwe: \def\stripnumber#1% {\cldcontext{lpeg.match(lpeg.stripper

Re: [NTG-context] Bug in Luatex file handling?

2021-06-15 Thread Hans Hagen
e call): >>>>>>>>>>io.open(filename,"r") filename=events/hga-0372-1764-63.xml=>file (0x7fff974160b8) Open file two levels deeper fails: >>>>>>>>>>io.open(filename,"r") filename=events/transcripten/hga-0372-1764

[NTG-context] Bug in Luatex file handling?

2021-06-15 Thread Hans van der Meer
>>>>>>io.open(filename,"r") filename=events/hga-0372-1764-63.xml=>file >>>>>>>>>>(0x7fff974160b8) Open file two levels deeper fails: >>>>>>>>>>io.open(filename,"r") >>>>>>>>>>file

Re: [NTG-context] \processassignmentlist inside a \setup... or related

2021-04-20 Thread Jairo A. del Rio
t; arguments = "2 strings", > > > > actions = registermydata > > > > } > > > > \stopluacode > > > > > > \unprotect > > > > \def\mysetups[#1]% > > > > {\getdummyparameters[#1]% > > > > \processassignmentlist[#1]\clf_registermy

Re: [NTG-context] \processassignmentlist inside a \setup... or related

2021-04-20 Thread Hans Hagen
= "registermydata", arguments = "2 strings", actions = registermydata } \stopluacode \unprotect \def\mysetups[#1]% {\getdummyparameters[#1]% \processassignmentlist[#1]\clf_registermydata} \protect \starttext \mysetups[love=nice,hate=awful]% \dummyparameter

[NTG-context] \processassignmentlist inside a \setup... or related

2021-04-19 Thread Jairo A. del Rio
"2 strings", actions = registermydata } \stopluacode \unprotect \def\mysetups[#1]% {\getdummyparameters[#1]% \processassignmentlist[#1]\clf_registermydata} \protect \starttext \mysetups[love=nice,hate=awful]% \dummyparameter{love} \cldcontext{userdata.mydata[2]} \stoptext

Re: [NTG-context] A not so short introduction to ConTeXt Mark IV

2021-01-11 Thread Ivan Pešić
: Re: [NTG-context] Randomize order of blocks > Following up my previous message, here is an example: > > %% begin shuffled list of exercises > \setuprandomize[2021] > > \startluacode > function shuffle(tableau) > local maxsize, t, tt >

Re: [NTG-context] Randomize order of blocks

2021-01-06 Thread Jairo A. del Rio
> "-2x\\sin(x^2)", > "x\\cos(x) + \\sin(x)", > "1 + \\tan(x)^2", > "3x^2 - 6x", > "\\frac{-2x}{(1 + x^2)^2}", > "\\frac{

Re: [NTG-context] Randomize order of blocks

2021-01-06 Thread Otared Kavian
"\\frac{\\cos(\\log(x))}{x}", } \stopluacode \starttext % We define a buffer and a shuffled list of integers \startbuffer[test-derivatives] \startluacode ShuffledList = shuffle({1,2,3,4,5,6}) \stopluacode Let $\cldcontext{ListOfNames[Shuffl

Re: [NTG-context] Issue with tex.romannumeral output

2020-11-25 Thread Jairo A. del Rio
Hi, Joseph. Something like this? \starttext \cldcontext{converters.convert("r",118):gsub("i$", "j") } \stoptext Jairo El mié, 25 de nov. de 2020 a la(s) 14:30, Joseph (josephcan...@gmail.com) escribió: > Yes, I replace last ‘i’ with a ‘j’ in roman number,

[NTG-context] RE : Issue with tex.romannumeral output

2020-11-25 Thread Joseph
sCc : JosephObjet :Re: [NTG-context] Issue with tex.romannumeral output Joseph schrieb am 25.11.2020 um 19:51:> Dear list,> > Following MWE outputs only ‘m’ characters (with latest upload). Is there a reason why you don't use the conversion mechanism? \starttext \convertnumber{r}{7} \cldcontext{conver

Re: [NTG-context] Issue with tex.romannumeral output

2020-11-25 Thread Wolfgang Schuster
Joseph schrieb am 25.11.2020 um 19:51: Dear list, Following MWE outputs only ‘m’ characters (with latest upload). Is there a reason why you don't use the conversion mechanism? \starttext \convertnumber{r}{7} \cldcontext{converters.convert("r",7)} \stoptext

Re: [NTG-context] non-ascii chars in cmd.exe (Windows)

2020-11-13 Thread Hans Hagen
\cldcontext{document.name} is the name. \stoptext [...] I’m using current latest (ConTeXt MkIV 2020.11.08 12:42). I’m not sure what I am missing or whether I have hit a bug. This has been discussed before I think. It has to do with how you configured your system (what encoding) and how

Re: [NTG-context] non-ascii chars in cmd.exe (Windows)

2020-11-13 Thread Pablo Rodriguez
On 11/12/20 10:55 PM, Hans Hagen wrote: > On 11/12/2020 10:39 PM, Pablo Rodriguez wrote: >> Dear list, >> >> I have the following sample: >> >>\starttext >>\startluacode >>io.write(' Name? ') >>document.name = io.read() or ''

Re: [NTG-context] non-ascii chars in cmd.exe (Windows)

2020-11-12 Thread Hans Hagen
On 11/12/2020 10:39 PM, Pablo Rodriguez wrote: Dear list, I have the following sample: \starttext \startluacode io.write(' Name? ') document.name = io.read() or '' \stopluacode \cldcontext{document.name} is the name. \stoptext Running it on Linux, I can input non-ascii

[NTG-context] non-ascii chars in cmd.exe (Windows)

2020-11-12 Thread Pablo Rodriguez
Dear list, I have the following sample: \starttext \startluacode io.write(' Name? ') document.name = io.read() or '' \stopluacode \cldcontext{document.name} is the name. \stoptext Running it on Linux, I can input non-ascii characters. When running in Windows, if the input chars

Re: [NTG-context] invoking ConTeXt from .bat file in Win7

2020-10-28 Thread Pablo Rodriguez
t with the first run mode. \startmode[*first] \startluacode io.write("\n\n Document URL?") document.url_address = io.read() \stopluacode \definedataset[document_data] \setdataset[document_data] [url=\cldcontext{document.url_address}] \stopmode \star

Re: [NTG-context] invoking ConTeXt from .bat file in Win7

2020-10-28 Thread Aditya Mahajan
e[*last] > > \startluacode > > io.write("¿Cuál es el mensaje? ") > > document.message = io.read() > > \stopluacode > > %~ \stopmode > > > > El mensaje es: \cldcontext{document.message} > > \stoptext > > > I

Re: [NTG-context] invoking ConTeXt from .bat file in Win7

2020-10-28 Thread Pablo Rodriguez
ocument.message = io.read() > \stopluacode > %~ \stopmode > > El mensaje es: \cldcontext{document.message} > \stoptext > > I have two questions about it. > > How can I invoke an extra run (as mentioned at > http://www.pragma-ade.com/general/manuals/

[NTG-context] invoking ConTeXt from .bat file in Win7

2020-10-27 Thread Pablo Rodriguez
Dear list, I have the following sample: \mainlanguage[es] \setupbodyfont[dejavu] \starttext %~ \startmode[*last] \startluacode io.write("¿Cuál es el mensaje? ") document.message = io.read() \stopluacode %~ \stopmode El mensaje es: \cldcontext{docume

[NTG-context] help with filename containing spaces

2020-10-17 Thread Pablo Rodriguez
Dear list, I have this sample: \setupinteraction[state=start] \starttext \def\cB{file.pdf} \def\cC{file with spaces.pdf} %~ \def\PathName{\cldcontext{[[\env{completepath}]]}} \def\PathName{% \cldcontext{string.gsub([[\env{completepath

Re: [NTG-context] need help comparing strings

2020-10-13 Thread Pablo Rodriguez
t;> return string.match(name, "%d+") >> end >>\stopluacode >> >>\define[1]\numbersfname >>{\cldcontext{userdata.numbersfname([==[#1]==])}} > > Untested: > > \defineexpandable[1]\numbersfname >   {\cldcontext{userd

Re: [NTG-context] need help comparing strings

2020-10-13 Thread Pablo Rodriguez
On 10/13/20 5:33 PM, Pablo Rodriguez wrote: > [...] > \starttext > \ctxlua{ d = [[\env{fname}]] } > > d: \cldcontext{d}\\ > \doifelse{\cldcontext{d:match("\letterpercent d+")}} > {123}{yes}{no} > \stoptext > [...] > 3. I’m trying this on

Re: [NTG-context] need help comparing strings

2020-10-13 Thread Wolfgang Schuster
communicating between tex and lua. For example: [...] \define[1]\numbersfname {\cldcontext{userdata.numbersfname([==[#1]==])}} This is the first time I see that way of wrapping an argument. In any case, I cannot compare to a number: \startluacode userdata = userdata or {} function

Re: [NTG-context] need help comparing strings

2020-10-13 Thread Pablo Rodriguez
and lua. For example: > [...] > \define[1]\numbersfname > {\cldcontext{userdata.numbersfname([==[#1]==])}} This is the first time I see that way of wrapping an argument. In any case, I cannot compare to a number: \startluacode userdata = userdata or {} funct

Re: [NTG-context] need help comparing strings

2020-10-13 Thread Wolfgang Schuster
Pablo Rodriguez schrieb am 13.10.2020 um 17:33: Dear list, I have the following sample: \starttext \def\numbersfname {\cldcontext{string.match([[\env{fname}]], "\letterpercent d+")}} \ctxlua{ c = context.getvariable("environment", "fname") or &quo

Re: [NTG-context] need help comparing strings

2020-10-13 Thread Aditya Mahajan
On Tue, 13 Oct 2020, Pablo Rodriguez wrote: > Dear list, > > I have the following sample: > > \starttext > \def\numbersfname > {\cldcontext{string.match([[\env{fname}]], "\letterpercent d+")}} > \ctxlua{ c = context.getvariable("environment"

[NTG-context] need help comparing strings

2020-10-13 Thread Pablo Rodriguez
Dear list, I have the following sample: \starttext \def\numbersfname {\cldcontext{string.match([[\env{fname}]], "\letterpercent d+")}} \ctxlua{ c = context.getvariable("environment", "fname") or "a" } \ctxlua{ d = [[\env{fname}]] } tex:

[NTG-context] Lua equivalent of \getvariable{}{}

2020-10-11 Thread Pablo Rodriguez
Dear list, I have the following sample: \starttext \ctxlua{ context.setvariable("environment", "filename", "abc123") } \ctxlua{ c = context.getvariable("environment", "filename") or "a" } \ctxlua{ d = [[\env{filename}]]

Re: [NTG-context] \doifelse not working, \doiftextelse breaking

2020-10-09 Thread Wolfgang Schuster
\def\startswith[#1][#2] {\cldcontext{document.starts_with("#1", "#2")}} You need a % at the end of the definition, otherwise TeX expects a space after the second argument to end the command. \unexpanded\def\startswith[#1][#2]% {...} To improve your comma

[NTG-context] \doifelse not working, \doiftextelse breaking

2020-10-09 Thread Pablo Rodriguez
Dear list, I have the following sample: \starttext \startluacode function document.starts_with(str, start) if str:sub(1, #start) == start then context(start) end end \stopluacode \unexpanded\def\startswith[#1][#2] {\cldcontext

Re: [NTG-context] playing with Windows drag & drop

2020-10-08 Thread context
any thanks for your reply, Lukas. I found another workaround at the ConTeXt file (b.tex). \cldcontext{string.gsub([[\env{PDFdocument}]], "", "/")} I don’t know why I needed to add "" instead of "\\". (otherwise, I I guess that's as Ctx translates &qu

Re: [NTG-context] playing with Windows drag & drop

2020-10-07 Thread Pablo Rodriguez
Lukas. I found another workaround at the ConTeXt file (b.tex). \cldcontext{string.gsub([[\env{PDFdocument}]], "", "/")} I don’t know why I needed to add "" instead of "\\". (otherwise, I kept getting "C://Users//username//Desktop//document.pdf

Re: [NTG-context] \setbreakpoints[compound] with numbers

2020-09-18 Thread Denis Maier
. Is there a way to deal with this? Perhaps something similar like \hyphenatedurl{} or an extended version of \setbreakpoints. (I currently use zero-width spaces, so I got rid of ISBNs in the margins, but a more automatic solution would be great.) \unexpanded\def\isbnnumber#1%   {\cldcontext

Re: [NTG-context] \setbreakpoints[compound] with numbers

2020-09-17 Thread Hans Hagen
something similar like \hyphenatedurl{} or an extended version of \setbreakpoints. (I currently use zero-width spaces, so I got rid of ISBNs in the margins, but a more automatic solution would be great.) \unexpanded\def\isbnnumber#1% {\cldcontext{string.gsub("#1","-","

Re: [NTG-context] catch % in gsub("%", "\\letterpercent")

2020-08-27 Thread Pablo Rodriguez
On 8/27/20 7:35 PM, Wolfgang Schuster wrote: > [...] > You have to replace %% with \letterpercent\letterpercent because you're > still playing with TeX rules. > > \startxmlsetups xml:special >     \startitem > \cldcontext{string.gsub("\xmlraw{#1}{.}"

Re: [NTG-context] catch % in gsub("%", "\\letterpercent")

2020-08-27 Thread Wolfgang Schuster
Pablo Rodriguez schrieb am 27.08.2020 um 19:16: On 8/27/20 6:16 PM, Wolfgang Schuster wrote: Pablo Rodriguez schrieb am 27.08.2020 um 17:56: [...] \startxmlsetups xml:special \startitem \cldcontext{string.gsub([[\xmlraw{#1}{.}]], "%%", "

Re: [NTG-context] catch % in gsub("%", "\\letterpercent")

2020-08-27 Thread Pablo Rodriguez
On 8/27/20 6:16 PM, Wolfgang Schuster wrote: > Pablo Rodriguez schrieb am 27.08.2020 um 17:56: >> [...] >>\startxmlsetups xml:special >> \startitem >> \cldcontext{string.gsub([[\xmlraw{#1}{.}]], "%%", >> "\\letterp

Re: [NTG-context] catch % in gsub("%", "\\letterpercent")

2020-08-27 Thread Wolfgang Schuster
xmlsetsetup{#1}{html}{xml:gen} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:gen \startitemize \xmlfilter{#1}{/**/span[@class='special']/command(xml:special)} \stopitemize \stopxmlsetups \startxmlsetups xml:special \startitem \cldcontext{stri

Re: [NTG-context] catch % in gsub("%", "\\letterpercent")

2020-08-27 Thread Pablo Rodriguez
up{#1}{html}{xml:gen} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:gen \startitemize \xmlfilter{#1}{/**/span[@class='special']/command(xml:special)} \stopitemize \stopxmlsetups \startxmlsetups xml:special \startitem \cldcontext{string.gsub([[\xmlr

Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Hans Hagen
...] \startxmlsetups xml:initialize \xmlsetsetup{#1}{html}{xml:gen} \xmlsetsetup{#1}{span[@class='special']}{xml:span:special} \stopxmlsetups [...] \startxmlsetups xml:span:special (\cldcontext{(string.gsub([[\xmlraw{#1}{.}]]," of the ", ""))}) \stopxmlsetups Many

Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Pablo Rodriguez
\startxmlsetups xml:initialize > \xmlsetsetup{#1}{html}{xml:gen} > \xmlsetsetup{#1}{span[@class='special']}{xml:span:special} > \stopxmlsetups > [...] > \startxmlsetups xml:span:special > (\cldcontext{(string.gsub([[\xmlraw{#1}{.}]]," of the ", ""

Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Pablo Rodriguez
string for you to modify. Many thanks for your explanation, Taco. > Also, the special (catcode, space handling) rules for setups and \cldcontext > do not help you. > > That does not mean it can’t be done. As I don’t know a of a nice way, > here is a low-level ‘ugly' way: >

Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Hans Hagen
\xmlfilter{#1}{/**/div/command(xml:special)} \stopxmlsetups \startxmlsetups xml:special %~ \startitem \cldcontext{string.gsub(lxml.flush([[#1]]), " of the ", "")}\stopitem \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stopte

Re: [NTG-context] removing word in filtered XML

2020-08-20 Thread Taco Hoekwater
up{#1}{html}{xml:gen} > \stopxmlsetups > > \xmlregistersetup{xml:initialize} > > \startxmlsetups xml:gen > \xmlfilter{#1}{/**/div/command(xml:special)} > \stopxmlsetups > > \startxmlsetups xml:special >%~ \startitem >\cldcontext{string.gsub(lxml.flush(

[NTG-context] removing word in filtered XML

2020-08-19 Thread Pablo Rodriguez
\startxmlsetups xml:special %~ \startitem \cldcontext{string.gsub(lxml.flush([[#1]]), " of the ", "")}\stopitem \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext Is there any way to remove " of " and " of the " in the fil

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

2020-02-27 Thread context
Hello Pablo, although I'm not sure about what to achieve, should this be helpful for you? Ctx source: Pablo.mkiv \starttext \setupheadertexts[][\cldcontext{"Mode = " .. (tex.modes["1"] and "1" or tex.modes["2"] and "2" or "??&q

Re: [NTG-context] How to use in Metafun, a function defined in Lua

2019-12-28 Thread Hans Hagen
)} $=\cldcontext{document.myfunction(2,355/113)} \sim 0$. \startplacefigure[title={Nothing works\dots}] \startMPcode{GridAxis} numeric gu ; gu = 5mm ; % gu = graph unit draw image ( draw function (1,"x","document.myfunction(2,x)", % <-- this does not wor

[NTG-context] How to use in Metafun, a function defined in Lua

2019-12-28 Thread Otared Kavian
) local S S = math.sin(n*x) return S end \stopluacode \starttext Here \type{document.myfunction(n,x)} is $\sin(nx)$. For instance when $n = 2$ and $x = 355/113$ we have: \type{document.myfunction(2,355/113)} $=\cldcontext{document.myfunction(2,355/113

Re: [NTG-context] issue embedding from Lua code

2019-11-01 Thread Wolfgang Schuster
anyone explain me what I’m doing wrong? You try to pass a protected (\expanded\def) command to a argument of another command which doesn't work: Remove \unexpanded and your output is as expected. \def\giveattachment#1%   {\cldcontext{document.special_attachment("#1")}} Many thanks for

Re: [NTG-context] issue embedding from Lua code

2019-11-01 Thread Pablo Rodriguez
e explain me what I’m doing wrong? > > You try to pass a protected (\expanded\def) command to a argument of > another command > which doesn't work: Remove \unexpanded and your output is as expected. > > \def\giveattachment#1% >   {\cldcontext{document.special_attachment

Re: [NTG-context] issue embedding from Lua code

2019-11-01 Thread Hans Hagen
, 10) attachment_url = "https://www.boe.es/buscar/pdf/; .. year .. "/" .. reference .. "-consolidado.pdf" return attachment_url end \stopluacode \unexpanded\def\giveattachment#1{% \cldcontext{document.special_attachment(

Re: [NTG-context] issue embedding from Lua code

2019-11-01 Thread Wolfgang Schuster
oe.es/buscar/pdf/; .. year .. "/" .. reference .. "-consolidado.pdf" return attachment_url end \stopluacode \unexpanded\def\giveattachment#1{% \cldcontext{document.special_attachment("#1")}} \def\cE{BOE-A-1978-31229}

[NTG-context] issue embedding from Lua code

2019-11-01 Thread Pablo Rodriguez
t; .. reference .. "-consolidado.pdf" return attachment_url end \stopluacode \unexpanded\def\giveattachment#1{% \cldcontext{document.special_attachment("#1")}} \def\cE{BOE-A-1978-31229} \attachment[file={\giveattachment{\cE}}, color=red] \attachm

Re: [NTG-context] expansion problem: random location

2019-09-14 Thread Wolfgang Schuster
the result of the first random value is stored in the macro.  \def\RandomA{\cldcontext{math.random(1,4)}} \edef\RandomB{\cldcontext{math.random(1,4)}} \starttext \dorecurse{10}{A: \RandomA \quad B: \RandomB\par} \stoptext Wolfgang

Re: [NTG-context] Manipulating the pagenumber in the TOC

2019-04-21 Thread Wolfgang Schuster
Willi Egger schrieb am 21.04.2019 um 19:28: Hi all, "when manipulating in one area you will have to manipulate also in other aeras” I must confess. I asked some time ago about manipulating the pagenumber. Wolfgang provide me the following approach: \cldcontext{“\letterperce

[NTG-context] Manipulating the pagenumber in the TOC

2019-04-21 Thread Willi Egger
Hi all, "when manipulating in one area you will have to manipulate also in other aeras” I must confess. I asked some time ago about manipulating the pagenumber. Wolfgang provide me the following approach: \cldcontext{“\letterpercent.0f”,(\pagenumber+1)/2} This works indeed fine. Howeve

Re: [NTG-context] Troubles with the \cldcontext command

2019-04-02 Thread Willi Egger
pulate the page number. However I > get an error: > > > MWE: > > \setuppapersize [A6] [A6] > > \setuppagenumbering[location=none] > > \startsetups [Pagenumber] > \doifrightpageelse >{\cldcontext{"\letterpercent d",(\pagenumber+1)/2}} >

Re: [NTG-context] Troubles with the \cldcontext command

2019-04-02 Thread Wolfgang Schuster
Willi Egger schrieb am 02.04.19 um 21:17: Hello! I have the following code, which should manipulate the page number. However I get an error: MWE: \setuppapersize [A6] [A6] \setuppagenumbering[location=none] \startsetups [Pagenumber] \doifrightpageelse {\cldcontext{"\letterpe

[NTG-context] Troubles with the \cldcontext command

2019-04-02 Thread Willi Egger
Hello! I have the following code, which should manipulate the page number. However I get an error: MWE: \setuppapersize [A6] [A6] \setuppagenumbering[location=none] \startsetups [Pagenumber] \doifrightpageelse {\cldcontext{"\letterpercent d",(\pagenumber+1)/2}} {} \

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

Re: [NTG-context] A strange request...

2019-02-20 Thread Wolfgang Schuster
[pagenumber] \doifoddpageelse {\cldcontext{"\letterpercent d",(\pagenumber+1)/2}} {} \stopsetups \setupheadertexts [\directsetup{pagenumber}] \starttext \dorecurse{10}{\samplefile{knuth}} \stoptext Variant 2: \defineexpandable[1]\DwarsliggerNumber {\cldcontext{"\

Re: [NTG-context] Define color with calculations

2019-02-18 Thread Henri Menke
lor[mycolor][r=0.5*0.7] > > \starttext > > \colored[r=\cldcontext{0.5*0.7}]{\cldcontext{0.5*0.7}} > > \colored[r=\cldcontext{"\letterpercent > .3f",0.5*0.7}]{\cldcontext{"\letterpercent .3f",0.5*0.7}} > > \stoptext > Better use \luaexpr. From th

Re: [NTG-context] Define color with calculations

2019-02-18 Thread Wolfgang Schuster
Mohammad Hossein Bateni schrieb am 18.02.19 um 04:37: Hi, When I use definecolor, (how) can I use computations in setting the value of a component?  Something like the following... \definecolor[mycolor][r=0.5*0.7] \starttext \colored[r=\cldcontext{0.5*0.7}]{\cldcontext{0.5*0.7}} \colored

Re: [NTG-context] XML and math

2019-01-10 Thread Hans Hagen
quot;15px" src="Lab01_eq10401623798909303081.png" width="95px"/> \stopbuffer \startxmlsetups whatever \xmlsetsetup{#1}{p|equation}{xml:*} \stopxmlsetups \xmlregistersetup{whatever} \startxmlsetups xml:p \xmlflush{#1} \stopxmlsetups \startxml

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] debug.getinfo

2018-11-22 Thread Hans Hagen
On 11/22/2018 2:05 PM, Procházka Lukáš Ing. wrote: Hello, the function 'debug.getinfo' was removed? The following code: \startluacode   print(debug.getinfo) \stopluacode \starttext   A \cldcontext{tostring(debug.getinfo)} \stoptext gives/prints 'nil'. IIRC, the function was non

Re: [NTG-context] debug.getinfo

2018-11-22 Thread luigi scarso
On Thu, Nov 22, 2018 at 2:02 PM Procházka Lukáš Ing. wrote: > Hello, > > the function 'debug.getinfo' was removed? > > The following code: > > > \startluacode >print(debug.getinfo) > \stopluacode > > \starttext >A \cldcontext{tostring(debug

[NTG-context] debug.getinfo

2018-11-22 Thread Procházka Lukáš Ing .
Hello, the function 'debug.getinfo' was removed? The following code: \startluacode print(debug.getinfo) \stopluacode \starttext A \cldcontext{tostring(debug.getinfo)} \stoptext gives/prints 'nil'. IIRC, the function was non-nil some weeks ago... Best regards, Lukas -- Ing

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

2018-08-13 Thread Henri Menke
/18 05:37, Jan U. Hasecke wrote: On 13.08.2018 17:57, Pablo Rodriguez wrote: if you don’t mind using Lua, here you have it: \starttext \def\duedate{\cldcontext{os.date('\letterpercent d/\letterpercent m/\letterpercent Y', os.time()+ 10 * 24 * 3600)}} \duedate

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

2018-08-13 Thread Jan U. Hasecke
On 13.08.2018 17:57, Pablo Rodriguez wrote: > if you don’t mind using Lua, here you have it: > > \starttext > \def\duedate{\cldcontext{os.date('\letterpercent d/\letterpercent > m/\letterpercent Y', os.time()+ 10 * 24 * 3600)}} > > \duedate > \st

  1   2   >