Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
Hi Hans. Only for explanation of my (maybe) crazy request: I can not at this level TeX macros to create, because it creates automatically after opening the CSV file. Although I tried to start creating something with \ csname \ endcsname etc. but my experiments with this method were never successful. In addition with TeX probably I can not work as well as with Lua (for things which in this case I need ie. at low level). Given that I have a CSV file loaded in global variables and header information at my disposal, I Lua everything you need me to do what I need. The problem is that the macros created in Lua I sometimes do not work as well when I create TeX (during the cycle will automatically fall short values). I have a particularly bad experience in this regard with the construction, he sent Taco. Simplified version of "interfaces.definecommand" construction does not in my way of processing the results of what I expected. Module which at the moment I work (in collaboration with Pablo Rodriguez) at the moment is very complex and extensive, and already it slowly begin to lose myself :-), so I try to get any information from the conference. Thank you and also to other counselors too at the conference for their cooperation in solve my problems. Jaroslav Hajtmar Dne 8. 7. 2015 v 20:54 Hans Hagen napsal(a): On 7/8/2015 4:11 PM, Jaroslav Hajtmar wrote: Thanks Taco very much. At this point, it really works in simple situations, but in the event that this solution will incorporate into the existing system, then I have big problems with expansion (values are not updated in macros). I need more solutions using something like context.setgvalue, or at least according to the following example. If they could incorporate the remaining two definitions ie \def\simpleA {content when parameter is missing} \def\complexA[#1]{parameter #1} into luacode (probably encounter a problem with #), so it might work. Can not think of anyone, how it could be done differently? Thanks Jaroslav Hajtmar Here is minimal example: \ctxlua{ xlsname='A' content='content when parameter is missing' context([[\definecomplexorsimple\]]..xlsname) %context([[\def\simple]]..xlsname..[[{]]..content..[[}]]) %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]]) } \def\simpleA {content when parameter is missing} \def\complexA[#1]{parameter #1} why don't you define these commands at the tex level Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Bibliography (bug compiling "components-001.tex"?)
Hello, On Wed, 08 Jul 2015 20:53:10 +0200, Hans Hagen wrote: On 7/8/2015 4:06 PM, Procházka Lukáš Ing. - Pontex s. r. o. wrote: Hello, I also tried one of the ConTeXt suite test files, namely: test\doc\context\tests\mkiv\bibtex\components-002.tex where I just commented two lines, so I got: % Was: components-001.tex % \endinput % to be adapted that file is not working now which is why it had an \endinput OK. Is there a way to have list of publications... - something like this to work: \startpublication [k=me, t=article, a=LPr, y=2000, s=Shr, n=1, ] \city{Prg} \stoppublication \starttext Hello \cite[me]. \placepublications[criterium=all] \stoptext So: - publications to be defined before \starttext, with each publication enclosed in \startpublication ... \stoppublication pairs, - \cite command to work, - list of publications via \placepublications to work. I mentioned this theme once in the mailing list - with subject "Bibliography" - but with no response... The bibtex/components-002.tex seemed to be quite close... Or: which is the recommended way to: - have a DB of publications (preferably in "standard" ConTeXt "space", not in a .bib file) - to refer to a publication - to build a list of publications? (A MWE or a link would be appreciated...) Best regards, Lukas Hans -- Ing. Lukáš Procházka | mailto:l...@pontex.cz Pontex s. r. o. | mailto:pon...@pontex.cz | http://www.pontex.cz Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 Fax: +420 244 461 038 ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Expansion in bookmarks
On 7/8/2015 4:18 PM, Christoph Reller wrote: Dear all! I want to define a command that is to be used in a section title. Also I want to use \autoinsertnextspace with this command. In the following MWE, why do \This and \AName not work, while \TEX does work? I appreciate any feedback, Christoph MWE: \setupinteraction[state=start] \setupinteractionscreen[option=bookmark] \placebookmarks[section][section] \def\What{This\autoinsertnextspace} \definesorting[Name] \setupsorting[Name][next=\autoinsertnextspace] \Name[AName]{Knuth} \usemodule[abr-01] \setupsorting[logo][next=\autoinsertnextspace] \starttext \startsection[title={\What is puzzling}]\stopsection \startsection[title={\AName is puzzling}]\stopsection \startsection[title={\TEX is puzzling}]\stopsection \stoptext you can try: \enabledirectives[references.bookmarks.preroll] or specify bookmarks with bookmark=... alongside the title= Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
On 7/8/2015 4:11 PM, Jaroslav Hajtmar wrote: Thanks Taco very much. At this point, it really works in simple situations, but in the event that this solution will incorporate into the existing system, then I have big problems with expansion (values are not updated in macros). I need more solutions using something like context.setgvalue, or at least according to the following example. If they could incorporate the remaining two definitions ie \def\simpleA {content when parameter is missing} \def\complexA[#1]{parameter #1} into luacode (probably encounter a problem with #), so it might work. Can not think of anyone, how it could be done differently? Thanks Jaroslav Hajtmar Here is minimal example: \ctxlua{ xlsname='A' content='content when parameter is missing' context([[\definecomplexorsimple\]]..xlsname) %context([[\def\simple]]..xlsname..[[{]]..content..[[}]]) %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]]) } \def\simpleA {content when parameter is missing} \def\complexA[#1]{parameter #1} why don't you define these commands at the tex level Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Bibliography (bug compiling "components-001.tex"?)
On 7/8/2015 4:06 PM, Procházka Lukáš Ing. - Pontex s. r. o. wrote: Hello, I also tried one of the ConTeXt suite test files, namely: test\doc\context\tests\mkiv\bibtex\components-002.tex where I just commented two lines, so I got: % Was: components-001.tex % \endinput % to be adapted that file is not working now which is why it had an \endinput Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
Thanks Taco very much. At this point, it really works in simple situations, but in the event that this solution will incorporate into the existing system, then I have big problems with expansion (values are not updated in macros). I need more solutions using something like context.setgvalue, or at least according to the following example. If they could incorporate the remaining two definitions ie \def\simpleA {content when parameter is missing} \def\complexA[#1]{parameter #1} into luacode (probably encounter a problem with #), so it might work. Can not think of anyone, how it could be done differently? Thanks Jaroslav Hajtmar Here is minimal example: \ctxlua{ xlsname='A' content='content when parameter is missing' context([[\definecomplexorsimple\]]..xlsname) %context([[\def\simple]]..xlsname..[[{]]..content..[[}]]) %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]]) } \def\simpleA {content when parameter is missing} \def\complexA[#1]{parameter #1} \type{\A}: \A \type{\A[5]}: \A[5] \stoptext Dne 8. 7. 2015 v 14:11 Taco Hoekwater napsal(a): On 08 Jul 2015, at 13:58, Jaroslav Hajtmar wrote: Thanx Taco for reply. the minimal example see bellow not crashed, but \A macro is not created. I don't Know in what could still be a problem. Example I am even more minimalize It works for me after changing \directlua {} to \startluacode … \stopluacode Best wishes, Taco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Expansion in bookmarks
Dear all! I want to define a command that is to be used in a section title. Also I want to use \autoinsertnextspace with this command. In the following MWE, why do \This and \AName not work, while \TEX does work? I appreciate any feedback, Christoph MWE: \setupinteraction[state=start] \setupinteractionscreen[option=bookmark] \placebookmarks[section][section] \def\What{This\autoinsertnextspace} \definesorting[Name] \setupsorting[Name][next=\autoinsertnextspace] \Name[AName]{Knuth} \usemodule[abr-01] \setupsorting[logo][next=\autoinsertnextspace] \starttext \startsection[title={\What is puzzling}]\stopsection \startsection[title={\AName is puzzling}]\stopsection \startsection[title={\TEX is puzzling}]\stopsection \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Bibliography (bug compiling "components-001.tex"?)
Hello, I also tried one of the ConTeXt suite test files, namely: test\doc\context\tests\mkiv\bibtex\components-002.tex where I just commented two lines, so I got: % Was: components-001.tex % \endinput % to be adapted % adapted example from list \startpublication[ k=me, t=manual, a=Hoekwater, y=2006, s=TH2006, n=1, u=http://contextgarden.net/Bibliography, ] \author{Taco}[T.]{}{Hoekwater} \title{\CONTEXT\ Publication Module, The user documententation} \pubyear{2006} \note{In case you didn’t know: it’s the document you are reading now} \pages{14} \stoppublication \startproduct components-001 \startfrontmatter % \component components-002 two: \cite[me] \stopfrontmatter \placepublications [criterium=text] \stopproduct But, I'm not able to compile even this file. I'm getting: mtx-context | run 1: luatex --fmt="c:/Ctx-Beta/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en" --interaction="nonstopmode" --jobname="Bib --c:path="C:\\Lukas\\ConTeXt\\Styles" "cont-yes.mkiv" This is LuaTeX, Version beta-0.80.1 (TeX Live 2015/W32TeX) (rev 5274) \write18 enabled. system > callbacks > not registering frozen 'find_format_file' open source > 1 > 1 > c:/Ctx-Beta/tex/texmf-context/tex/context/base/cont-yes.mkiv ConTeXt ver: 2015.07.01 21:40 MKIV beta fmt: 2015.7.2 int: english/english system > 'cont-new.mkiv' loaded open source > 2 > 2 > c:/Ctx-Beta/tex/texmf-context/tex/context/base/cont-new.mkiv close source> 2 > 2 > c:/Ctx-Beta/tex/texmf-context/tex/context/base/cont-new.mkiv system > jobfiles > using path: C:\\Lukas\\ConTeXt\\Styles system > files > jobname 'Bib', input 'd:\\Lukas\\ConTeXt\\Test\\Bib.mkiv', result 'Bib' fonts > latin modern fonts are not preloaded languages > language 'en' is active open source > 2 > 3 > d://Lukas/ConTeXt/Test/Bib.mkiv fonts > preloading latin modern fonts (second stage) fonts > 'fallback modern-designsize rm 12pt' is loaded structures > begin of sectionblock 'frontpart' publications> analyzing previous publication run for 'default' lua error > error on line 30 in file d://Lukas/ConTeXt/Test/Bib.mkiv: c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:513: attempt to index field '?' (a nil value) stack traceback: c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:513: in function 'register' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:591: in function 'findallused' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:2503: in function 'processcite' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:2814: in function '?' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:2304: in function (...tail calls...) 20 \pages{14} 21 \stoppublication 22 23 \startproduct components-001 24 25 \startfrontmatter 26 27 % \component components-002 28 29 two: \cite[me] 30 >> 31 \stopfrontmatter 32 33 \placepublications 34 [criterium=text] 35 36 \stopproduct 37 structures > end of sectionblock 'frontpart' backend > xmp > using file 'c:/Ctx-Beta/tex/texmf-context/tex/context/base/lpdf-pdx.xml' pages > flushing realpage 1, userpage 1 lua error > error on line 33 in file d://Lukas/ConTeXt/Test/Bib.mkiv: c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:513: attempt to index field '?' (a nil value) stack traceback: c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:513: in function 'register' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:591: in function 'findallused' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:2503: in function 'processcite' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:2814: in function '?' c:/Ctx-Beta/tex/texmf-context/tex/context/base/publ-ini.lua:2304: in function (...tail calls...) 23 \startproduct components-001 24 25 \startfrontmatter 26 27 % \component components-002 28 29 two: \cite[me] 30 31 \stopfrontmatter 32 33 >> \placepublications 34 [criterium=text] 35 36 \stopproduct 37 pages > flushing realpage 2, userpage 2 close source> 2 > 3 > d://Lukas/ConTeXt/Test/Bib.mkiv close source> 1 > 3 > c:/Ctx-Beta/tex/texmf-context/tex/context/base/cont-yes.mkiv ... mtx-context | fatal error: return code: 1 The full log is attached... What is wrong? Best regards, Lukas -- Ing. Lukáš Procházka | mailto:l...@pontex.cz Pontex s. r. o. | mailto:pon...@pontex.cz | http://www.pontex.cz Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 Fax: +420 244 461 038 Bib.log Description: Binary data Bib.mkiv Description: Binary data
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
> On 08 Jul 2015, at 13:58, Jaroslav Hajtmar wrote: > > Thanx Taco for reply. > > the minimal example see bellow not crashed, but \A macro is not created. > I don't Know in what could still be a problem. Example I am even more > minimalize It works for me after changing \directlua {} to \startluacode … \stopluacode Best wishes, Taco cld-def-test.tex Description: Binary data ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
Thanx Taco for reply. the minimal example see bellow not crashed, but \A macro is not created. I don't Know in what could still be a problem. Example I am even more minimalize Thanx Jaroslav \starttext \directlua{ xlsname='A' interfaces.definecommand ('do'..xlsname, { arguments = { { "option", "string" } }, macro = function (opt_1) if #opt_1>0 then context(opt_1) else context('nothing') end end }) interfaces.definecommand (xlsname, { macro = function () context.dosingleempty() context['do'..xlsname]() end }) } % \A[5] % % % \A \stoptext Dne 8. 7. 2015 v 13:28 Taco Hoekwater napsal(a): On 08 Jul 2015, at 13:04, Jaroslav Hajtmar wrote: Hi Taco. full deployment is unfortunately not working. Unfortunately I need to cycle create different macros whose names are variable. At this moment I can not deal with this: --- context.doxlsname() --- ? context[‘do’..xlsname]() Thanx Jaroslav Hajtmar here is another minimal example: \starttext \def\linepointer{5} \def\csvcell[#1,#2]{cell #1,#2} \directlua{ xlsname='A' interfaces.definecommand ('do'..xlsname, { arguments = { { "option", "string" } }, macro = function (opt_1) if #opt_1>0 then context('\\csvcell["'..xlsname..'",'..opt_1..']') else context('\\csvcell["'..xlsname..'",\\linepointer]') end end }) interfaces.definecommand (xlsname, { macro = function () context.dosingleempty() --- context.doxlsname() --- ? end }) } \csvcell['Firstname',\linepointer] \A \A[5] \stoptext Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a): \startluacode interfaces.definecommand ('dolastname', { arguments = { { "option", "string" } }, macro = function (opt_1) if #opt_1>0 then context(opt_1) else context('nothing') end end }) interfaces.definecommand ('lastname', { macro = function () context.dosingleempty() context.dolastname() end }) \stopluacode ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
> On 08 Jul 2015, at 13:04, Jaroslav Hajtmar wrote: > > Hi Taco. > full deployment is unfortunately not working. > > Unfortunately I need to cycle create different macros whose names are > variable. At this moment I can not deal with this: > > --- context.doxlsname() --- ? context[‘do’..xlsname]() > Thanx Jaroslav Hajtmar > > here is another minimal example: > > > > \starttext > > > \def\linepointer{5} > > \def\csvcell[#1,#2]{cell #1,#2} > > > \directlua{ > xlsname='A' > interfaces.definecommand ('do'..xlsname, { >arguments = { { "option", "string" } }, >macro = function (opt_1) > if #opt_1>0 then context('\\csvcell["'..xlsname..'",'..opt_1..']') > else context('\\csvcell["'..xlsname..'",\\linepointer]') end >end > }) > interfaces.definecommand (xlsname, { >macro = function () > context.dosingleempty() > --- context.doxlsname() --- ? >end > }) > } > > > \csvcell['Firstname',\linepointer] > > > \A > > \A[5] > > > > > \stoptext > > > > Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a): >> \startluacode >> interfaces.definecommand ('dolastname', { >> arguments = { { "option", "string" } }, >> macro = function (opt_1) >>if #opt_1>0 then context(opt_1) else context('nothing') end >> end >> }) >> interfaces.definecommand ('lastname', { >> macro = function () >>context.dosingleempty() >>context.dolastname() >> end >> }) >> \stopluacode > ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
Hi Taco. full deployment is unfortunately not working. Unfortunately I need to cycle create different macros whose names are variable. At this moment I can not deal with this: --- context.doxlsname() --- ? Thanx Jaroslav Hajtmar here is another minimal example: \starttext \def\linepointer{5} \def\csvcell[#1,#2]{cell #1,#2} \directlua{ xlsname='A' interfaces.definecommand ('do'..xlsname, { arguments = { { "option", "string" } }, macro = function (opt_1) if #opt_1>0 then context('\\csvcell["'..xlsname..'",'..opt_1..']') else context('\\csvcell["'..xlsname..'",\\linepointer]') end end }) interfaces.definecommand (xlsname, { macro = function () context.dosingleempty() --- context.doxlsname() --- ? end }) } \csvcell['Firstname',\linepointer] \A \A[5] \stoptext Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a): \startluacode interfaces.definecommand ('dolastname', { arguments = { { "option", "string" } }, macro = function (opt_1) if #opt_1>0 then context(opt_1) else context('nothing') end end }) interfaces.definecommand ('lastname', { macro = function () context.dosingleempty() context.dolastname() end }) \stopluacode ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
Thanks Taco, your solution helped me ... Based on initial tests, it seems that it works correctly. I'll know more after thorough testing. Once again, thank you many times. Sincerely Jaroslav Hajtmar Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a): On 08 Jul 2015, at 11:05, Jaroslav Hajtmar wrote: Hello ConTeXist. Within the one very complex problem I need to solve the following case. I want using lua code to define a macro with one optional parameter in brackets. Simplest solution I know is this: \startluacode interfaces.definecommand ('dolastname', { arguments = { { "option", "string" } }, macro = function (opt_1) if #opt_1>0 then context(opt_1) else context('nothing') end end }) interfaces.definecommand ('lastname', { macro = function () context.dosingleempty() context.dolastname() end }) \stopluacode Best wishes, Taco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using lua to define a macro with one optional parameter in brackets
> On 08 Jul 2015, at 11:05, Jaroslav Hajtmar wrote: > > Hello ConTeXist. > > Within the one very complex problem I need to solve the following case. I > want using lua code to define a macro with one optional parameter in brackets. Simplest solution I know is this: \startluacode interfaces.definecommand ('dolastname', { arguments = { { "option", "string" } }, macro = function (opt_1) if #opt_1>0 then context(opt_1) else context('nothing') end end }) interfaces.definecommand ('lastname', { macro = function () context.dosingleempty() context.dolastname() end }) \stopluacode Best wishes, Taco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Using lua to define a macro with one optional parameter in brackets
Hello ConTeXist. Within the one very complex problem I need to solve the following case. I want using lua code to define a macro with one optional parameter in brackets. I tried it using commands context.setgvalue, or find something on the wiki (http://wiki.contextgarden.net/System_Macros/Definitions_and_Assignments), but each time I broke a tooth on it. Can you, please, someone advise how something can be it done? Suffice some reference to solve a similar problem. Thanks Jaroslav Hajtmar Here is my minimal example: \starttext \def\lastname{\dosingleempty\dolastname} \def\dolastname[#1]{\iffirstargument #1\else nothing\fi} \lastname \lastname[Smith] % Not working % \ctxlua{ % context([[\def\firstname{\dosingleempty\dofirstname}]]) % context([[\def\dofirstname[#1]{\iffirstargument #1\else {nothing}\fi}]]) % } % % \firstname % % \firstname['Peter'] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___