\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.
\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.
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
nt = "short", righttext = righttext})
context("]")
end
\stopluacode
\startsetups btx:aps:cite:special
\btxcitereference
\ctxlua{render_cite([==[\currentbtxdataset]==], [==[\currentbtxtag]==],
[==[\currentbtxrighttext]==])}
\stopsetups
\setupbtx[aps:cite][al
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\stopTestQuestions
{\ctxlua{userdata.for
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
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?
\setupinteraction
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
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 {%
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
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
...
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
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
> 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
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
riptprefix{\typescriptone}] [\ctxlua{context(userdata.adobesource.getfontname("\typescriptone", "\typescripttwo", false, false))}] [features=default]
\definefontsynonym [\typescriptprefix{\typescriptone}Italic] [\ctxlua{context(userdata.adobesource.getfontname("\typ
@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
_,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{#
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
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
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
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
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
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
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
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
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
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
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
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
}
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
'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
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->
...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
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.
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
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
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
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
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"
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")}
\
script }
)
context.start()
context.addff("f:"..name)
context(test)
context.stop()
context.blank()
end
end
end
\stopluacode
\definedfont[LibertinusSerif-Regular.otf*always]
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
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
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{%
\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
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
\st
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 }
0.5\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:
>
&g
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
chars = 0
end
n = n.next
end
return head
end
nodes.tasks.appendaction(
"processors",
"before",
"userdata.limiter"
)
\stopluacode
\setupp
\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
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
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
...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
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
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
gt; >
> > ```
> >
> > \starttexdefinition loc [#1]
> >
> > \doifassignmentelse{#1} {
> >
> > % if an assignment, then parse and format accordingly
> >
> > \getparameters[loc][#1]
> >
> > % Was a section number specified?
> >
>
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}
-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
{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}{
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
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
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
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
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("
\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
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\def\Tra
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
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
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
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
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,
text = nil
\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
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
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
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
{}
> >
> >local comment = [[
> > This is a famous formula
> > \startformula
> >a^2 + b^2 = c^2
> > \stopformula
> >]]
> >
> >function thirddata.explanation()
> >context(comment)
> >en
_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 - 100 of 1165 matches
Mail list logo