[NTG-context] Re: defining hashtag simulator

2024-05-20 Thread Hans Hagen
\Hashtag#1{ \hbox{\tfa\ctxlua{ str = "#1" replacespace = string.gsub(str," ","_") context.letterhash() context(replacespace) } } } \starttext \Hashtag{hello} \stoptext i used hbox for making phrase unbreakable.

[NTG-context] Re: defining hashtag simulator

2024-05-20 Thread Hans Hagen via ntg-context
\Hashtag#1{ \hbox{\tfa\ctxlua{ str = "#1" replacespace = string.gsub(str," ","_") context.letterhash() context(replacespace) } } } \starttext \Hashtag{hello} \stoptext i used hbox for making phrase unbreakable.

[NTG-context] Re: defining hashtag simulator

2024-05-20 Thread seyal . zavira
Thanks. What if we want the text to be copied when it is clicked? I found these link on the stack site for this https://tex.stackexchange.com/questions/174637/copy-to-clipboard-feature-in-pdf-output/545107#545107 also i defined this: \def\Hashtag#1{ \hbox{\tfa\ctxlua{ str = &qu

[NTG-context] Re: Combine lua and btx setup, was: Re: Customize citation format of a bibliography (use the short form as reference format)

2024-04-25 Thread Gerion Entrup
nt = "short", righttext = righttext}) context("]") end \stopluacode \startsetups btx:aps:cite:special \btxcitereference \ctxlua{render_cite([==[\currentbtxdataset]==], [==[\currentbtxtag]==], [==[\currentbtxrighttext]==])} \stopsetups \setupbtx[aps:cite][al

[NTG-context] Combine lua and btx setup, was: Re: Customize citation format of a bibliography (use the short form as reference format)

2024-04-23 Thread Gerion Entrup
ot;[>" .. short .. "]") else context("[" .. short .. "]") end end \stopluacode \definebtx[aps:cite:special][aps:cite] \startsetups btx:aps:cite:special \btxcitereference \ctxlua{render_cite([==[\btxflush{year}]==], [==[\btxflush{

[NTG-context] Re: \luaescapestring in proper Lua

2024-04-11 Thread Pablo Rodriguez via ntg-context
On 4/11/24 18:56, Hans Hagen via ntg-context wrote: > [...] >>> \protected\def\PrintTheThing{\ctxlua{document.print_the_thing()}} >> >> Sorry, but why \protected is required or recommended here? > > depends if you want it to be expandable I see now that "still.

[NTG-context] Re: \luaescapestring in proper Lua

2024-04-11 Thread Hans Hagen via ntg-context
On 4/11/2024 5:07 PM, Pablo Rodriguez via ntg-context wrote: On 4/10/24 21:48, Hans Hagen via ntg-context wrote: On 4/10/2024 7:49 PM, Pablo Rodriguez via ntg-context wrote: [...] I wonder whether there is a proper way in the Lua code to avoid [[\luaescapestring{}]] in \ctxlua

[NTG-context] Re: \luaescapestring in proper Lua

2024-04-11 Thread Pablo Rodriguez via ntg-context
On 4/10/24 21:48, Hans Hagen via ntg-context wrote: > On 4/10/2024 7:49 PM, Pablo Rodriguez via ntg-context wrote: >> [...] >> I wonder whether there is a proper way in the Lua code to avoid >> [[\luaescapestring{}]] in \ctxlua. >> [...] > context(tokens.s

[NTG-context] Re: \luaescapestring in proper Lua

2024-04-10 Thread Hans Hagen via ntg-context
On 4/10/2024 7:49 PM, Pablo Rodriguez via ntg-context wrote: Dear list, I have the following sample: \starttext \startluacode function document.print_the_thing(str) context(str) end \stopluacode \unexpanded\def\PrintTheThing#1{% \ctxlua{document.print_the_thing

[NTG-context] \luaescapestring in proper Lua

2024-04-10 Thread Pablo Rodriguez via ntg-context
Dear list, I have the following sample: \starttext \startluacode function document.print_the_thing(str) context(str) end \stopluacode \unexpanded\def\PrintTheThing#1{% \ctxlua{document.print_the_thing([[\luaescapestring{#1}]])}} \PrintTheThing{a \em b {c}} \stoptext I

[NTG-context] Re: using an end of line as parameter

2024-02-21 Thread Bruce Horrocks
Reset for the next question (in case no blank line) tracker = 0 the_question = {} end end end \stopluacode \def\startTestQuestions {\dostartbuffer[TestQuestions][startTestQuestions][stopTestQuestions]} \def\stopTestQuestions {\ctxlua{userdata.for

[NTG-context] Re: using an end of line as parameter

2024-02-20 Thread Bruce Horrocks
k line) tracker = 0 the_question = {} end end end \stopluacode \def\startTestQuestions {\dostartbuffer[TestQuestions][startTestQuestions][stopTestQuestions]} \def\stopTestQuestions {\ctxlua{userdata.formatTestQuestions()}} \starttext Here are some questions: \s

[NTG-context] Re: removing whitespace

2024-02-13 Thread Wolfgang Schuster
Michael Guravage schrieb am 13.02.2024 um 14:01: While reading the documentation I spotted something similar from which I derived this solution: \setupinteraction[state=start] \def\squeeze#1%   {     \goto{#1} [url(tel:\ctxlua{context(string.gsub("#1", " ", "")

[NTG-context] Re: removing whitespace

2024-02-13 Thread Michael Guravage
While reading the documentation I spotted something similar from which I derived this solution: \setupinteraction[state=start] \def\squeeze#1% { \goto{#1} [url(tel:\ctxlua{context(string.gsub("#1", " ", ""))})] } \starttext Call \squeeze{01234 56789

[NTG-context] removing whitespace

2024-02-12 Thread Michael Guravage
In the example below I pass the macro a string with a space, but the space should not appear in the url. I've tried using \ctxlua to invoke string substitution, but without success. What is the proper way to remove this space, and to perform string manipulation more generally? \setupinteraction

[NTG-context] Re: Own command definition breaks with interaction: Use of \do_my_command doesn't match its definition

2024-01-29 Thread Wolfgang Schuster
context(text) end end \stopluacode % without that line there is no problem \setupinteraction[state=start] \defineenumeration[enu][text=Enu] \defineenumeration[enu][text=Enu,title=yes] \unprotect \def\mc{\dosingleempty\do_my_command} \def\do_my_command[#1]#2{% \iffirstargumen

[NTG-context] Re: Own command definition breaks with interaction: Use of \do_my_command doesn't match its definition

2024-01-29 Thread Taco Hoekwater
t line there is no problem > \setupinteraction[state=start] > > \defineenumeration[enu][text=Enu] > > \unprotect > \def\mc{\dosingleempty\do_my_command} > \def\do_my_command[#1]#2{% > \iffirstargument{% > \ctxlua{userdata.my_command('#1', [==[#2]==])}% > }\else {%

[NTG-context] Own command definition breaks with interaction: Use of \do_my_command doesn't match its definition

2024-01-25 Thread Gerion Entrup
nd end \stopluacode % without that line there is no problem \setupinteraction[state=start] \defineenumeration[enu][text=Enu] \unprotect \def\mc{\dosingleempty\do_my_command} \def\do_my_command[#1]#2{% \iffirstargument{% \ctxlua{userdata.my_command('#1', [==[#2]==])}% }\el

[NTG-context] Re: vim syntax highlighting bug?

2024-01-09 Thread Gerion Entrup
t; > > > > > Happy New Year! > > > > I got into a bug in my Vim syntax highlighting version. > > Highlight stays in lua mode after ctxlua macro is closed. > > Here is a MWE, where «this should not be highlitghted as > > a comment indeed is

[NTG-context] Re: vim syntax highlighting bug?

2024-01-08 Thread Vincent Hennebert
ghlighting version. Highlight stays in lua mode after ctxlua macro is closed. Here is a MWE, where «this should not be highlitghted as a comment indeed is. \starttext Hello! \ctxlua{context("does the parser work?")} -- this should not be highlighted as a comment \stoptext Do

[NTG-context] Re: vim syntax highlighting bug?

2024-01-06 Thread Christian Prim via ntg-context
... Hope it helps Christian Am Sa., 6. Jan. 2024 um 13:04 Uhr schrieb Damien Thiriet via ntg-context < ntg-context@ntg.nl>: > Hello, > > > Happy New Year! > > I got into a bug in my Vim syntax highlighting version. > Highlight stays in lua mode after ctxlua macro is clo

[NTG-context] vim syntax highlighting bug?

2024-01-06 Thread Damien Thiriet via ntg-context
Hello, Happy New Year! I got into a bug in my Vim syntax highlighting version. Highlight stays in lua mode after ctxlua macro is closed. Here is a MWE, where «this should not be highlitghted as a comment indeed is. \starttext Hello! \ctxlua{context("does the parser work?")} -- t

[NTG-context] Re: LMTX: Command handling, Interface between TeX and Lua

2023-12-14 Thread Gerion Entrup
> context('Color chosen = ' .. named_values['color']) > context('\\par') > context('Curly braces = ' .. str) > context('\\par') > end > \stopluacode > > \def\mycommand[#1][#2]#3{\ctxlua{ > userdata.mycommand('#1', '#2', [==[#3]==])}} > > \startt

[NTG-context] Re: LMTX: Command handling, Interface between TeX and Lua

2023-12-13 Thread Bruce Horrocks
named_values = utilities.parsers.settings_to_hash(keyvals) context('First option = ' .. keyword_options[1]) context('\\par') context('Color chosen = ' .. named_values['color']) context('\\par') context('Curly braces = ' .. str) context('\\par') end \stopluacode \def\mycommand[#1

[NTG-context] Adobe Source Typescript With Design Sizes

2023-10-31 Thread Vincent Hennebert
riptprefix{\typescriptone}] [\ctxlua{context(userdata.adobesource.getfontname("\typescriptone", "\typescripttwo", false, false))}] [features=default] \definefontsynonym [\typescriptprefix{\typescriptone}Italic] [\ctxlua{context(userdata.adobesource.getfontname("\typ

[NTG-context] Re: XML: flush to lua function

2023-09-12 Thread Taco Hoekwater
@ntg.nl > Betreff: [NTG-context] XML: flush to lua function > Hi, > I have the following xml setup with a lua function: > \startluacode > function markingLength(s) > _,n = s:gsub("%S+","") > if n > 3 the

[NTG-context] Re: XML: flush to lua function

2023-09-12 Thread denis.maier
_,n = s:gsub("%S+","") if n > 3 then context("yes" .. " ...") else context("no") end end \stopluacode \startxmlsetups xml:ink:ink-title:marking %\ctxlua{markingLength(\xmlflush{#

[NTG-context] XML: flush to lua function

2023-09-11 Thread denis.maier
end end \stopluacode \startxmlsetups xml:ink:ink-title:marking %\ctxlua{markingLength(\xmlflush{#1})} % does not work \ctxlua{markingLength{"1 2 3 4"}} \stopxmlsetups While the function works, I cannot use xmlflush here. How can I p

[NTG-context] Re: Table head/body via lua

2023-08-18 Thread Wolfgang Schuster
commands, like \bTABLEhead, \eTABLEhead, bTABLEbody or \eTABLEbody: it seems impossible to incapsulate them into lua functions. For example, the following is not compiled: \starttext \bTABLE \ctxlua{context.bTABLEbody()} \bTR \bTD Cell 1\eTD \bTD Cell 2\eTD \eTR \ctxlua{context.eTABLEbody()} \eTABLE

[NTG-context] Table head/body via lua

2023-08-18 Thread Alexey Kryukov
or \eTABLEbody: it seems impossible to incapsulate them into lua functions. For example, the following is not compiled: \starttext \bTABLE \ctxlua{context.bTABLEbody()} \bTR \bTD Cell 1\eTD \bTD Cell 2\eTD \eTR \ctxlua{context.eTABLEbody()} \eTABLE \stoptext Can anybody suggest a workaround

[NTG-context] Re: Why overbar is so big

2023-08-13 Thread Hans Hagen
ail calls...) [ctxlua]:1: in main chunk 25 \subsubject{Versió} 26 27 Contínuament canvio aquest document, afegint, modificant o eliminant algunes parts seves. En aquest sentit, és una obra permanentment inacabada. Per aquest motiu convé saber quina versió del document esteu llegi

[NTG-context] Re: Why overbar is so big

2023-08-13 Thread Xavier B.
ile './lualibs-os/init.lua' stack traceback: [C]: in upvalue 'requiem' ...nt/tex/texmf-context/tex/context/base/mkiv/l-sandbox.lua:180: in function <...nt/tex/texmf-context/tex/context/base/mkiv/l-sandbox.lua:165> (...tail calls...) [ctxlua]:1: in main

[NTG-context] Problems with luametatex and texlive on OpenBSD

2023-07-27 Thread Edd Barrett
nTeXt Core Macros / Environments resolvers > lua > loading file '/usr/local/share/texmf-dist/tex/context/base/mkxl/core-env.lmt' succeeded close source> level 1, order 35, name 'core-env.mkxl' open source > level 1, order 36, name 'layo-ini.mkxl' loading > C

[NTG-context] Fwd: Re: Replacing %20 with spaces in xml attributes

2023-07-21 Thread Hans Hagen via ntg-context
thinking that it has something to do with the percent characters... This here works just fine: \startluacode function test(s) result = string.gsub(s, 'x20', 'MATCH') context(result) end \stopluacode \define[1]\test{\ctxlua{test("#1")}} \starttext \test{asdfx20} % -> asdfMA

[NTG-context] Re: Replacing %20 with spaces in xml attributes

2023-07-21 Thread denis.maier
Thanks, but I'm still getting the same error. I'm thinking that it has something to do with the percent characters... This here works just fine: \startluacode function test(s) result = string.gsub(s, 'x20', 'MATCH') context(result) end \stopluacode \define[1]\test{\ctxlua{test(&qu

[NTG-context] Re: Replacing %20 with spaces in xml attributes

2023-07-21 Thread Hans van der Meer via ntg-context
with some Lua, but I don’t really know how to pass data around. > > % > \startluacode > function replaceSpaces(s) > result = string.gsub(s, "%%20", " ") > context(result) > end > \stopluacode > > \define[1]\replaceSpaces{\ctxlua{replaceSpaces("#1&q

[NTG-context] Replacing %20 with spaces in xml attributes

2023-07-21 Thread denis.maier
ine[1]\replaceSpaces{\ctxlua{replaceSpaces("#1")}} \startxmlsetups xml:fig:graphic \externalfigure[\replaceSpaces{\xmlatt{#1}{xlink:href}}] \stopxmlsetups % Any hints, why this does not work?` Also, maybe there's a simpler way for this

[NTG-context] Re: access image properties in Lua

2023-07-17 Thread Henning Hraban Ramm
the scaled target size of an image; either the "current" one or by name. \ctxlua{inspect(figures.getinfo("t:/sources/mill.png").used)} \ctxlua{inspect(figures.getinfo("t:/sources/mill.png").status)} etc .. no more faking the img lib Thank you! We also might have a

[NTG-context] Re: access image properties in Lua

2023-07-17 Thread Alan Braslau via ntg-context
scaled target size of an image; either the "current" one or by name. \ctxlua{inspect(figures.getinfo("t:/sources/mill.png").used)} \ctxlua{inspect(figures.getinfo("t:/sources/mill.png").status)} etc .. no more faking the img lib Hans Hraban, Hans, and mailing l

[NTG-context] Re: access image properties in Lua

2023-07-13 Thread Hans Hagen
} if I understand this right, "img" isn’t valid anymore: """ token call, execute: grph-imagelib.lua:37: attempt to index a nil value (global 'img') """ I’d like to know the pixel size and if possible also the scaled target size of an image; either the &q

[NTG-context] [ error installing fresh lmtx]

2023-05-29 Thread vm via ntg-context
'code' ...ext/tex/texmf-context/tex/context/base/mkiv/util-lua.lua:96: in field 'loadedluacode' ...ext/tex/texmf-context/tex/context/base/mkiv/luat-env.lua:108: in field 'luafilechunk' ...ext/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:73: in function 'lua.registercode' [\di

Re: [NTG-context] Is there a way to centrally add a list of indexed items to a sub category?

2023-05-15 Thread Henning Hraban Ramm via ntg-context
Index lookups \defineregister[Person][] \defineprocessor[italics][style=italicface] \define[1]\Passim{\emph{passim}} \defineprocessor[passim][command=\Passim] \define[1]\nPerson{% \expanded{\Person{\ctxlua{userdata.Lookup("#1")}}}% } \define[1]\TPerson{% \expanded{\Person[kursiv->

Re: [NTG-context] cannot generate format file with current latest

2023-04-30 Thread Bruce Horrocks via ntg-context
...ext/base/mkxl/cldf-pos.lmt:18: in local 'code' > ...ext/base/mkiv/util-lua.lua:96: in field 'loadedluacode' > ...ext/base/mkiv/luat-env.lua:108: in field 'luafilechunk' > ...ext/base/mkxl/luat-cod.lmt:82: in function 'lua.registercode' > [ctxlua]:1: in main chunk > > A number sh

[NTG-context] cannot generate format file with current latest

2023-04-30 Thread Pablo Rodriguez via ntg-context
t-env.lua:108: in field 'luafilechunk' ...ext/base/mkxl/luat-cod.lmt:82: in function 'lua.registercode' [ctxlua]:1: in main chunk A number should have been here; I inserted '0'. (If you can't figure out why I needed to see a number, look up 'weird error' in the index to The TeXbook.

[NTG-context] cannot compile with MkIV

2023-03-06 Thread Pablo Rodriguez via ntg-context
108: in field 'luafilechunk' ...ext/tex/texmf-context/tex/context/base/mkiv/luat-cod.lua:73: in function 'lua.registercode' [ctxlua]:1: in main chunk 11 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for 12 %C details. 13 14 %D The less there is here, the better. A

Re: [NTG-context] \hpos in math - Half solved

2022-12-07 Thread Hans Hagen via ntg-context
the same labels (X,Y,Z), but internally they have separate sets, (1:X and 2:X, etc.). The moral of the story for me: Use more Lua. but ... work local ... so document.sfnum etc in order to avoid clashes Gavin % Lua counts the spin formulas \ctxlua{sfnum = 0} % Count starts at zero \def\sfID

Re: [NTG-context] \hpos in math - Half solved

2022-12-07 Thread Gavin via ntg-context
more Lua. Gavin % Lua counts the spin formulas \ctxlua{sfnum = 0} % Count starts at zero \def\sfID{\ctxlua{context(sfnum)}} % ConTeXt can call the count from Lua to use as an ID for each equation. % Spin formulas increase the spin formula count and typeset the formula as usual. \define

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] filling buffers in cld documents

2022-11-27 Thread Hans Hagen via ntg-context
txcell {"width=1.5cm","align=flushright"} context(Eleve[note]) context("/") context(notemax)   context.stopxcell ()    end    \stopluacode    \startbuffer [grille]    \startxtable       \startxrow \startxcell     \ct

[NTG-context] filling buffers in cld documents

2022-11-27 Thread damien thiriet via ntg-context
context(Eleve[note]) context("/") context(notemax) context.stopxcell () end \stopluacode \startbuffer [grille] \startxtable \startxrow \startxcell \ctxlua {userdata.Critere ("structure","NoteStructure"

Re: [NTG-context] Font expansion enabled by default with the latest upload

2022-11-21 Thread Max Chernoff via ntg-context
hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello.% \ctxlua{nodes.tasks.enableaction("finalizers", "userdata.test")} \ctxlua{nodes.tasks.disableaction("finalizers", "userdata.test")} \

Re: [NTG-context] font features

2022-11-03 Thread Hans Hagen via ntg-context
script } ) context.start() context.addff("f:"..name) context(test) context.stop() context.blank() end end end \stopluacode \definedfont[LibertinusSerif-Regular.otf*always]

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

2022-09-22 Thread Pablo Rodriguez via ntg-context
Dear list, playing with buffer contents, I have the following file: \setupinteraction[state=start] \setupinteractionscreen[option={attachment}] \startbuffer[test] just a test and another one \stopbuffer \starttext \ctxlua{require("util-sha")} \def\s

[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] Parallel texts: verse with blanks between stanzas via tabulate

2022-08-29 Thread Hans Hagen via ntg-context
rue, public= true, actions = poetry.sidebyside, arguments = "hash", } \stopluacode \continueifinputfile{m-poetry.mkxl} \starttext \starttext \startbuffer[lines-1] THIS IS A POEM WITH TWO STANZAS \stopbuffer \startbuffer[lines-1b] THIS IS A LONGER POEM WITH T

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] Parallel texts: verse with blanks between stanzas via tabulate

2022-08-28 Thread Hans Hagen via ntg-context
\stopbuffer \startbuffer[lines-2] this is a poem with two stanzas \stopbuffer \startbuffer[lines-3] this | THIS is | IS a| A poem | POEM | with | WITH two | TWO stanzas | STANZAS \stopbuffer \ctxlua { moduledat

Re: [NTG-context] Is rendering furigana over horizontal or vertical japanese text doable in ConTeXt?

2022-08-21 Thread Hans Hagen via ntg-context
offset 3pt{\strut #1}} \setbox1000\hbox{\NotoCJK\startscript[hangul]\dorecurse{20}{通用规范汉字表 \stripe{test #1} }\stopscript} \ctxlua{document.manipulate_one(1000)} \ruledvbox orientation 1 to \textwidth \bgroup \hsize \textheight \unhbox1000 \vfill \egroup \page \setbox1000\hbox{\N

Re: [NTG-context] Can't manipulate glue added by tex.preparelinebreak

2022-07-26 Thread Hans Hagen via ntg-context
{\dorecurse{209}{Hello }\par}\page {\parfillskip=0pt\dorecurse{209}{Hello }\par}\page {\ctxlua{nodes.tasks.appendaction("processors", "after", "test")} \dorecurse{209}{Hello }\par}\page \box\testbox \st

[NTG-context] Can't manipulate glue added by tex.preparelinebreak

2022-07-26 Thread Max Chernoff via ntg-context
tretch = 0 local broken = tex.linebreak(new_head) tex.setbox("global", "testbox", broken) return head end \stopluacode \starttext {\dorecurse{209}{Hello }\par}\page {\parfillskip=0pt\dorecurse{209}{Hello }

Re: [NTG-context] How to switch off the numbering of a float in a CLDocument?

2022-07-21 Thread Taco Hoekwater via ntg-context
0.5\textwidth}] Best wishes, Taco PS \enabletrackers[context.*] > --context.framedtext( > -- {frame="on",style="\\bfd"}, > -- "{This is a test}") > context.stopplacefigure() > end > > \stopluacode &g

Re: [NTG-context] How to switch off the numbering of a float in a CLDocument?

2022-07-21 Thread Willi Egger via ntg-context
-- "{This is a test}") context.stopplacefigure() end \stopluacode \define\Test{\ctxlua{Foto_page()}} \starttext \strut \Test \stoptext KR Willi > On 18 Jul 2022, at 20:56, Henning Hraban Ramm via ntg-context > wrote: > &g

Re: [NTG-context] Count (and limit) glyphs per line?

2022-06-26 Thread Hans Hagen via ntg-context
such as: \setuppapersize[landscape,letter] \showframe \starttext \samplefile{knuth} \ctxlua{context(tex.dimen["textwidth"])} % 37213340 \ctxlua{context(tex.dimen["localhsize"])} % 0 \startitemize[width=5em] \item \samplefile{knuth

Re: [NTG-context] Count (and limit) glyphs per line?

2022-06-26 Thread Benjamin Buchmuller via ntg-context
chars = 0 end n = n.next end return head end nodes.tasks.appendaction( "processors", "before", "userdata.limiter" ) \stopluacode \setupp

Re: [NTG-context] Count (and limit) glyphs per line?

2022-06-25 Thread Benjamin Buchmuller via ntg-context
\samplefile{knuth} \ctxlua{context(tex.dimen["textwidth"])} % 37213340 \ctxlua{context(tex.dimen["localhsize"])} % 0 \startitemize[width=5em] \item \samplefile{knuth} \ctxlua{context(tex.dimen["

Re: [NTG-context] How to print a random whole number between x and y?

2022-06-17 Thread Wolfgang Schuster via ntg-context
Joel via ntg-context schrieb am 17.06.2022 um 16:10: I was using this code for a long time in my document. I have a PDF with 10 pages, and this would randomly display one of those pages:    \ctxlua{math.randomseed( os.time() )}         \getrandomnumber \n {1} {10}      \placefigure

[NTG-context] How to print a random whole number between x and y?

2022-06-17 Thread Joel via ntg-context
I was using this code for a long time in my document. I have a PDF with 10 pages, and this would randomly display one of those pages:    \ctxlua{math.randomseed( os.time() )}                  \getrandomnumber \n {1} {10}              \placefigure[force, none]{}{\framed[frame=off

[NTG-context] \doifnotdocumentargument in proper Lua

2022-04-29 Thread Pablo Rodriguez via ntg-context
Dear list, I have the following command in one of my documents: \doifnotdocumentargument{no-metadata} {\ctxlua{document.transfer_metadata(document.main_file)}} Which would be the right way to write \doifnotdocumentargument in proper Lua? Many thanks for your help, Pablo

Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-25 Thread Eduardo Bohoyo via ntg-context
triggers \everysetuplwc which then calls \ctxlua{lwc.enable_callbacks()}. This fails since lwc is undefined because the Lua file isn't loaded because ConTeXt can't seem to find the file. In Plain LuaTeX and LuaLaTeX, a missing Lua file is a fatal error:     $ luatex "\nonstopmode\dire

Re: [NTG-context] lua-widow-control module error in LMTX

2022-04-25 Thread Max Chernoff via ntg-context
a-widow-control file is empty. The \setuplwc command ends on line 74, which then triggers \everysetuplwc which then calls \ctxlua{lwc.enable_callbacks()}. This fails since lwc is undefined because the Lua file isn't loaded because ConTeXt can't seem to find the file. In Plain LuaTeX and LuaLaTeX

Re: [NTG-context] gzip.compress in ConTeXt mkiv

2022-03-02 Thread Hans Hagen via ntg-context
...mtx/tex/texmf-context/tex/context/base/mkiv/util-zip.lua:610: in upvalue 'putcompressed' ...mtx/tex/texmf-context/tex/context/base/mkiv/util-zip.lua:662: in function 'gzip.compress' [ctxlua]:1: in main chunk i'll check it (at some point i need to split code paths a bit mo

[NTG-context] gzip.compress in ConTeXt mkiv

2022-03-01 Thread Marcel Fabian Krüger via ntg-context
n upvalue 'putcompressed' ...mtx/tex/texmf-context/tex/context/base/mkiv/util-zip.lua:662: in function 'gzip.compress' [ctxlua]:1: in main chunk Best regards, Marcel ___ If your question is of interest to othe

Re: [NTG-context] Reset environment between MetaPost graphics?

2022-01-21 Thread Vincent Hennebert via ntg-context
On Thu, 2022-01-20 at 15:47 +0100, Hans Hagen via ntg-context wrote: > On 1/20/2022 3:26 PM, Aditya Mahajan via ntg-context wrote: > > > AFAIK, there is no in-built support for this. > > FYEO: > > \starttext > > \startMPcode >      u = 123; > \stopMPcode &g

Re: [NTG-context] Reset environment between MetaPost graphics?

2022-01-20 Thread Hans Hagen via ntg-context
On 1/20/2022 3:26 PM, Aditya Mahajan via ntg-context wrote: AFAIK, there is no in-built support for this. FYEO: \starttext \startMPcode u = 123; \stopMPcode \ctxlua{metapost.reset("metafun:1")} \startMPcode u = 123; \stopMPcode \stoptext (the instance is reported on t

[NTG-context] getting sha512 from text in buffer

2021-12-01 Thread Pablo Rodriguez via ntg-context
Dear list, I have this minimal sample: \ctxlua{require("util-sha")} \def\sha#1{% \ctxlua{context(utilities.sha2.hash512("#1"))}} \startbuffer[text] hola \stopbuffer \starttext \sha{hola} \sha{\typebuffer[text]} \stoptext How can I get that both c

Re: [NTG-context] Checking for a Unicode prefix of a Unicode string

2021-11-27 Thread Joey McCollum via ntg-context
gt; > > > ``` > > > > \starttexdefinition loc [#1] > > > > \doifassignmentelse{#1} { > > > > % if an assignment, then parse and format accordingly > > > > \getparameters[loc][#1] > > > > % Was a section number specified? > > >

Re: [NTG-context] Checking for a Unicode prefix of a Unicode string

2021-11-27 Thread Hans Hagen via ntg-context
sec } } { % otherwise, just print the input as-is #1 } \stoptexdefinition \def\DoIfPrefixElse#1#2{\ctxlua{commands.doifelse(string.find([==[#2]==],"^"..[==[#1]==]))}} \def\currentbtxloctext{\loc[sec=31]} \starttext \currentbtxloctext\blank \DoIfPrefixElse{§}{\currentbtxloctext}

Re: [NTG-context] Checking for a Unicode prefix of a Unicode string

2021-11-27 Thread Joey McCollum via ntg-context
-is #1 } \stoptexdefinition \def\DoIfPrefixElse#1#2{\ctxlua{commands.doifelse(string.find([==[#2]==],"^"..[==[#1]==]))}} \def\currentbtxloctext{\loc[sec=31]} \starttext \currentbtxloctext\blank \DoIfPrefixElse{§}{\currentbtxloctext}{YES}{NOP} \stoptext ``` Indeed, if I add a simple

Re: [NTG-context] Checking for a Unicode prefix of a Unicode string

2021-11-26 Thread Joey McCollum via ntg-context
{locsec} { § \locsec\btxcomma } } { % otherwise, just print the input as-is #1 } \stoptexdefinition \def\DoIfPrefixElse#1#2{\ctxlua{commands.doifelse(string.find("#2","^".."#1"))}} \def\currentbtxloctext{\loc[sec=31]} \starttext \DoIfPrefixElse{§}{\currentbtxloctext}{

Re: [NTG-context] Checking for a Unicode prefix of a Unicode string

2021-11-26 Thread Hans Hagen via ntg-context
    return true     end     return false   end ``` how about if string.find(str,"^"..prefix) then in: \starttext \def\DoIfPrefixElse#1#2{\ctxlua{commands.doifelse(string.find("#2","^".."#1"))}} \DoIfPrefixElse{pre}{prefix}{YES}{NOP} \DoIfPrefixE

Re: [NTG-context] Checking for a macro in a string without expanding it

2021-11-16 Thread Hans Hagen via ntg-context
inside the brackets     end     context(innerparams)     return end \stopluacode \def\parseinner#1{\ctxlua{userdata.parseinner([==[#1]==])}} \starttext Testing:\blank \parseinner{\outer} \stoptext ``` My problem is that when I pass \outer to the \parseinner macro, it gets fully expanded

Re: [NTG-context] Checking for a macro in a string without expanding it

2021-11-16 Thread Jairo A. del Rio via ntg-context
t;) then > > i, j = string.find(str, "\\inner(%b[])") > > innerparams = string.sub(str, i+1, j-1) -- we just want the content > inside the brackets > > end > > context(innerparams) > > return > > end > > \stopluacode > > \def

[NTG-context] Checking for a macro in a string without expanding it

2021-11-16 Thread Joey McCollum via ntg-context
innerparams = "" if string.find(str, "\\inner(%b[])") then i, j = string.find(str, "\\inner(%b[])") innerparams = string.sub(str, i+1, j-1) -- we just want the content inside the brackets end context(innerparams) return end \stopluac

Re: [NTG-context] getting number from context.figurewidth

2021-10-28 Thread Pablo Rodriguez via ntg-context
dth >> .. ' height=' .. context.figureheight) >> >> I cannot concatenate string and function (and I need the number, not the >> unit). >> >> Is there no way of doing it? > i'm pretty sure this has been asked before > > \ctxlua{local f = figures.getinfo("

Re: [NTG-context] getting number from context.figurewidth

2021-10-27 Thread Hans Hagen via ntg-context
\ctxlua{local f = figures.getinfo("cow.pdf") print(f and f.used and f.used.width)} so .. time to wikify it Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061

Re: [NTG-context] setting date in \setupinteraction

2021-10-19 Thread Michal Vlasák via ntg-context
itle = main_doc.Info.Title } > context.setupinteraction{ date = main_doc.Info.ModDate:sub(3,6) .. > "-" .. main_doc.Info.ModDate:sub(7,8) .. "-" .. > main_doc.Info.ModDate:sub(9,10) .. "T" .. > main_doc.Info.ModDate:sub(11,12) .. ":" .. > main_doc.Info.ModDate:sub(13,14) .. &quo

Re: [NTG-context] setting date in \setupinteraction

2021-10-19 Thread Pablo Rodriguez via ntg-context
in_doc.Info.ModDate:sub(11,12) .. ":" .. main_doc.Info.ModDate:sub(13,14) .. ":" .. main_doc.Info.ModDate:sub(15,22):gsub("'", ":") } context(main_doc.Info.Title .. "\\par") lpdf.epdf.unload(name) end \stopluacode \unexpanded\def\Tra

Re: [NTG-context] Reading ConTeXt metadata values into Lua

2021-10-17 Thread Ramkumar KB via ntg-context
could not catch on how to read a metadata value (not print). I am sure > >> that I am missing a small trick somewhere (or is it something more > >> involved?). > >> > >> \startluacode > >> function myFancyCalculations(pages) > >> -- some fancy s

Re: [NTG-context] Reading ConTeXt metadata values into Lua

2021-10-16 Thread Hans Hagen via ntg-context
ow to read a metadata value (not print). I am sure that I am missing a small trick somewhere (or is it something more involved?). \startluacode function myFancyCalculations(pages)   -- some fancy stuff but as an example local myCal = tonumber(pages) + 1 return myCal \stopluacode \starttext \bla

Re: [NTG-context] Reading ConTeXt metadata values into Lua

2021-10-16 Thread Wolfgang Schuster via ntg-context
ng a small trick somewhere (or is it something more involved?). \startluacode function myFancyCalculations(pages)   -- some fancy stuff but as an example local myCal = tonumber(pages) + 1 return myCal \stopluacode \starttext \blah \ctxlua{context(myFancyCalculations("\\totalnumberofpages

[NTG-context] Reading ConTeXt metadata values into Lua

2021-10-15 Thread Ramkumar KB via ntg-context
artluacode function myFancyCalculations(pages) -- some fancy stuff but as an example local myCal = tonumber(pages) + 1 return myCal \stopluacode \starttext \blah \ctxlua{context(myFancyCalculations("\\totalnumberofpages"))} \stoptext Thank you in advance for any tips. be

Re: [NTG-context] Acrobat doesn’t read imported metadata

2021-10-10 Thread Hans Hagen via ntg-context
nexpanded\def\TransferMetadata#1% {\ctxlua{document.transfer_metadata("#1")}} \startTEXpage[offset=1em, align=center] \ssbf metadatos\\importados \TransferMetadata{metadata.pdf} \stopTEXpage \stoptext Being the sample file https://pdf.ousia.tk/metadata.pdf, Acrobat can

[NTG-context] Acrobat doesn’t read imported metadata

2021-10-10 Thread Pablo Rodriguez via ntg-context
ot;CreationDate", lpdf.string(main_doc.Info.CreationDate)) lpdf.addtoinfo("ModDate", lpdf.string(main_doc.Info.ModDate), main_doc.Info.ModDate) lpdf.epdf.unload(name) end \stopluacode \unexpanded\def\TransferMetadata#1% {\ctxlua{document.transfer_metadata(&quo

Re: [NTG-context] Default values for key-value macros

2021-10-10 Thread Hans Hagen via ntg-context
, but I'm having problems with the following MWE: ``` \def\style#1[#2] {   \ctxlua{userdata.style([==[#2]==])}   \placestyle } here you overload a core macro \startluacode   userdata = userdata or {}   userdata.style = function(keyvals)     local style = {       color = nil,       text = nil

[NTG-context] Default values for key-value macros

2021-10-10 Thread noib3 via ntg-context
\style#1[#2] { \ctxlua{userdata.style([==[#2]==])} \placestyle } \startluacode userdata = userdata or {} userdata.style = function(keyvals) local style = { color = nil, text = nil, } args = utilities.parsers.settings_to_hash(keyvals) for k, v in pairs(args) do

[NTG-context] Acrobat doesn’t display some imported metadata

2021-09-19 Thread Pablo Rodriguez via ntg-context
lpdf.addtoinfo("ModDate", lpdf.string(main_doc.Info.ModDate), main_doc.Info.ModDate) lpdf.epdf.unload(name) end \stopluacode \unexpanded\def\TransferMetadata#1% {\ctxlua{document.transfer_metadata("#1")}} \startTEXpage[offset=1em, align=center] \ssbf me

Re: [NTG-context] Exclude bibliographic entries from list even when cited with \cite

2021-09-16 Thread Hans Hagen via ntg-context
ications.btx.slb = { } this is tricky and will clash: \def\ordinal#1{\ctxlua{sblhelpers.ordinal([==[#1]==])}}% \def\convertdate#1{\ctxlua{sblhelpers.convertdate([==[#1]==])}}% \def\serializelocationpublisher#1#2{\ctxlua{sblhelpers.serializelocationpublisher([==[#1]==],[==[#2]==])}}% \def\serializevolumenumberdatepage

Re: [NTG-context] Weird error when using \startformula inside lua

2021-09-12 Thread Sylvain Hubert via ntg-context
This is a famous formula > \startformula > a^2 + b^2 = c^2 > \stopformula > ]] > > function thirddata.explanation() > context(comment) > end > > \stopluacode > > \starttext > \ctxlua{thirddata.explanation()} > \stoptext > > The actual us

Re: [NTG-context] Weird error when using \startformula inside lua

2021-09-11 Thread Aditya Mahajan via ntg-context
{} > > > >local comment = [[ > > This is a famous formula > > \startformula > >a^2 + b^2 = c^2 > > \stopformula > >]] > > > >function thirddata.explanation() > >context(comment) > >en

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

2021-09-11 Thread Pablo Rodriguez via ntg-context
_doc.Catalog.Lang)) lpdf.addtoinfo("Title", lpdf.unicode(main_doc.Info.Title)) lpdf.addtoinfo("Subject", lpdf.unicode(main_doc.Info.Subject)) lpdf.addtoinfo("Author", lpdf.unicode(main_doc.Info.Author)) lpdf.epdf.unload(name)

  1   2   3   4   5   6   7   8   9   10   >