Re: [NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle
Actually, the backslashes disappear before the call to textext() G > On 1 Apr 2020, at 23:44, Aditya Mahajan wrote: > > On Wed, 1 Apr 2020, Gerben Wierda wrote: >> >> My route is probably to complex anyway, but what can I do for the curly >> braces to be actually typeset? > > MkII had a feature called \sometxt > http://dl.contextgarden.net/myway/sometxt.pdf > > I wonder if that still works in MkIV. > > Aditya > ___ > 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://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle
On Wed, 1 Apr 2020, Gerben Wierda wrote: My route is probably to complex anyway, but what can I do for the curly braces to be actually typeset? MkII had a feature called \sometxt http://dl.contextgarden.net/myway/sometxt.pdf I wonder if that still works in MkIV. Aditya ___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Lua/TeX/METAPOST/textext string issue/puzzle
I have lua code that generates this for METAPOST: ApplicationComponentLogo( w, h, "withcolor (0.686,1.000,1.000) withtransparency (1,0.200)", "withcolor (0.000,0.000,0.000) withtransparency (1,1.000) withpen pencircle scaled 1.000", "\{Hello\}, "&"(a)"&" [World]!") shifted (x, -y); draw pic; The string to be typeset, eventually is this: {Hello}, "(a)" [World]! So, with double quotes in the string. The function creating the actual string to pass to METAPOST (above) is this: local function mpLabelString( xmlLabelString) -- Returns a string where each " is replaced by a METAPOST compatible result, except for outer double quotes" rep = { [1] = { "\"", "\"&\"" }, } local tmpString = string.formatters( "%!tex!", xmlLabelString) return lpeg.replacer(rep):match(tmpString) end That works. Then, in METAPOST the vardef ‘ApplicationComponentLogo’ calls a vardef makeTeXLabel draw makeTeXLabel( w, h, name) shifted (w/2,0); which, for now, simplified does this: vardef makeTeXLabel( expr w, h, name) = save p; picture p ; save s; string s; s := "\framed{" & name & "}”; % s := "\type-" & name & "-"; p := textext( s); p enddef; But, this is what is in string s before it is sent to textext(): \framed {{Hello}, "(a)" [World]!} In other words, the escapes on the curly braces are lost and now the curly braces are ignored by TeX. I tried adding a doubling of the backslahes to the replacement: rep = { [1] = { "\"", "\"&\"" }, [2] = { "\\", "" }, } But then the string that is typeset (and given to textext()) becomes \framed {\\{Hello\\}, "(a)" [World]!} And the result in the output is the same. No curly braces. My route is probably to complex anyway, but what can I do for the curly braces to be actually typeset? G___ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Lua and metapost
Hi all, Since ConTeXt has LuaTeX and it contains Lua interpreter so I wonder if it is possible to write Lua code which can generate Metapost code for graphics. MetaLua can also help here. However, I do not know how to develop a Lua library which can be integrated with ConTeXt but then again I have not looked in this matter. As you people may be knowing Prof. John Hobby has written a Haskell frontend for Metapost which generates Metapost code. Having a Lua version of same will help a lot. My only concern is using MetaLua with ConTeXt. -- Best regards, Shiv Shankar Dayal ___ 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] Lua and metapost
Hi, Please discard previous mail as I did not know about MPlib. On Fri, May 21, 2010 at 12:48 AM, Shiv Shankar Dayal shivshankar.da...@gmail.com wrote: Hi all, Since ConTeXt has LuaTeX and it contains Lua interpreter so I wonder if it is possible to write Lua code which can generate Metapost code for graphics. MetaLua can also help here. However, I do not know how to develop a Lua library which can be integrated with ConTeXt but then again I have not looked in this matter. As you people may be knowing Prof. John Hobby has written a Haskell frontend for Metapost which generates Metapost code. Having a Lua version of same will help a lot. My only concern is using MetaLua with ConTeXt. -- Best regards, Shiv Shankar Dayal -- Best regards, Shiv Shankar Dayal ___ 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 ___