xt(userdata.Mapping[name] or name)
end
%%% environment
\loadluafile[lookups.lua]
\defineregister[Location][]
\define[1]\LocIndex{\expanded{\Location{%
\ctxlua{userdata.Lookup("#1")
Hraban
___
If
od.lmt:82: in
function 'lua.registercode'
[ctxlua]:1: in main chunk
You injected something that confused the parser, maybe by using some Lua
call.
resolvers | formats |
resolvers | formats | binary path :
/Users/me/context/tex/texmf-osx-64/bin
resolvers |
ableH(i,year)
context.page()
end
end
\stopluacode
% Setup of the month table
\startsetups table:month
\setupTABLE[c]
[each]
[width=\dimexpr\textwidth/7,
frame=on,
style=\tfa]
\setupTABLE[r][each][height=1.8\lineheight,align={center,lohi
On 6/8/24 10:49, vm via ntg-context wrote:
> in the document
> https://wiki.contextgarden.net/images/8/8c/xhtml.pdf
>
> near the end an essential line got truncated:
> [...]
> how should this line continue ?
> {\externalfigure[\xmlatt{#1}{src}][width=\ctxlua{getmeas("
On 6/8/24 10:49, vm via ntg-context wrote:
in the document
https://wiki.contextgarden.net/images/8/8c/xhtml.pdf
near the end an essential line got truncated:
\startxmlsetups xml:img
\placefigure[here]
[\xmlatt{#1}{src}]
{\xmlatt{#1}{alt}}
{\externalfigure[\xmlatt{#1}{src}][width=\ctxlua
in the document
https://wiki.contextgarden.net/images/8/8c/xhtml.pdf
near the end an essential line got truncated:
\startxmlsetups xml:img
\placefigure[here]
[\xmlatt{#1}{src}]
{\xmlatt{#1}{alt}}
{\externalfigure[\xmlatt{#1}{src}][width=\ctxlua{getmeas("\xmla
\stopxmlsetups
how should
\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.
How c
\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.
How c
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
ag,
variant = "short", righttext = righttext})
context("]")
end
\stopluacode
\startsetups btx:aps:cite:special
\btxcitereference
\ctxlua{render_cite([==[\currentbtxdataset]==], [==[\currentbtxtag]==],
[==[\currentbtxrighttext]==])}
\stopsetups
\setupbtx[ap
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{
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.
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
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
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
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
-- 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\stopTestQuestion
ion (in case no blank line)
tracker = 0
the_question = {}
end
end
end
\stopluacode
\def\startTestQuestions
{\dostartbuffer[TestQuestions][startTestQuestions][stopTestQuestions]}
\def\stopTestQuestions
{\ctxlua{userdata.formatTestQuestions()}}
\starttext
Here are
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", " ", "")
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
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?
\setupintera
;] then
context.bold(text)
else
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
> % 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',
text(text)
end
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
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
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 other
ersion 9.0...
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 ma
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
1])
> context('\\par')
> context('Color chosen = ' .. named_values['color'])
> context('\\par')
> context('Curly braces = ' .. str)
> context('\\par')
> end
> \stopluacode
>
> \def\mycommand[#1][#2]#
to_array(keywords)
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
riptprefix{\typescriptone}] [\ctxlua{context(userdata.adobesource.getfontname("\typescriptone", "\typescripttwo", false, false))}] [features=default]
\definefontsynonym [\typescriptprefix{\typescriptone}Italic] [\ctxlua{context(userdata.adobesource.getfontname("\typ
esendet: Montag, 11. September 2023 16:47
> An: ntg-context@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+","&qu
_,n = s:gsub("%S+","")
if n > 3 then
context("yes" .. " ...") else context("no") end
end
\stopluacode
\startxmlsetups xml:ink:ink-title:marking
%\ctxlua{markingLength(\
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
oning 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()}
\e
Ebody 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 worka
on
<...nt/tex/texmf-context/tex/context/base/mkiv/l-sandbox.lua:165>
(...tail 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 pe
it.lua'
no file './lualibs-os.lua'
no file './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/cont
> loading interface definitions from
'mult-def.lua'
interface > initialization > loading interface messages from
'mult-mes.lua'
interface > initialization > definitions: 746 constants, 637 variables,
28 elements, 865 commands, 191 formats, 21 tra
. 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("#1")}}
\starttext
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
\d
e/expand the
> %20s to regular spaces?
>
> I’ve tried 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
>
opluacode
\define[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 s
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
so 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
Hans
Hraban, Hans, and maili
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; eit
ext/tex/texmf-context/tex/context/base/mkiv/lxml-lpt.lua:64: in
local '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/te
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->
back:
> ...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'
>
;
...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 should have been here; I inserted '0'. (If you can't figure out
why I needed to
ontext/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'
[ctxlua]:1: in main chunk
11 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12 %C details.
13
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
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
t we need more 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
txcell {"width=1.5cm","align=flushright"}
context(Eleve[note])
context("/")
context(notemax)
context.stopxcell ()
end
\stopluacode
\startbuffer [grille]
\startxtable
\startxrow
\startxcell
\ct
context(Eleve[note])
context("/")
context(notemax)
context.stopxcell ()
end
\stopluacode
\startbuffer [grille]
\startxtable
\startxrow
\startxcell
\ctxlua {userdata.Critere ("structure","NoteStructure"
ello
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")}
"yes", script = script }
)
context.start()
context.addff("f:"..name)
context(test)
context.stop()
context.blank()
end
end
end
\stopluacode
\definedfont[LibertinusS
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
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
= true,
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
PO
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{%
NZAS
\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 {
modu
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
{\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
\stoptex
kip.stretch = 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}{He
textwidth}]
Best wishes,
Taco
PS \enabletrackers[context.*]
> --context.framedtext(
> -- {frame="on",style="\\bfd"},
> -- "{This is a test}")
> context.stopplacefigure()
> end
>
> \stopluacode
&g
-- "{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:
>
>
:
\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
chars = 0
end
n = n.next
end
return head
end
nodes.tasks.appendaction(
"processors",
"before",
"userdata.limiter"
)
\stopluacode
\setuppapersize[A5]
\showf
\samplefile{knuth}
\ctxlua{context(tex.dimen["textwidth"])} % 37213340
\ctxlua{context(tex.dimen["localhsize"])} % 0
\startitemize[width=5em]
\item \samplefile{knuth}
\ctxlua{context(tex.dimen["
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
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
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
\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, a missing Lua file
75 of the t-lua-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
...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
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
Best regards,
Marcel
___
If your q
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
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
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
> instead of "YES":
> >
> > ```
> >
> > \starttexdefinition loc [#1]
> >
> > \doifassignmentelse{#1} {
> >
> > % if an assignment, then parse and format accordingly
> >
> > \getparameters[loc][#1]
> >
> > % Was a sectio
\locsec
}
} {
% 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{§}{\currentbtxloc
ut 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}{YES}{NOP}
\stoptext
```
Indeed, if I add a s
fined{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{§}{\currentbtxloct
) == prefix then
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}{N
t want the
content 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 get
ot;\\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
>
> \stoplu
rseinner(str)
local 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)
re
t.figurewidth
>> .. ' 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
his has been asked before
\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
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
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\de
n the distro but
> >> 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)
&
ro but
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 stuff but as an example
local myCal = tonumber(pages) + 1
return myCal
t). 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
\blah
\ctxlua{context(myFancyCalculati
omething 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"))}
\stoptext
Thank yo
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
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
, 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,
1 - 100 of 1195 matches
Mail list logo