catcode problems (mkiv)
Hi, I have some problems with catcode handling in lua and tex. Source of the problem is (aside from my limited knowledge) a XML based line of text that can contain any printable character. From this source line I create one modified text line for the tex side (named 'textext') and one unmodified text line for the lua side (named 'luatext'). The tex side actually prints the text and the lua side is used to create some bitmap based background graphics. The XSLT output is something like this (saved in a *.tex file) ... \ctxlua{myluacode.foo{ luatext = [[Test |%_^~$#{}±©®¶°<>& 123]], textext = [[Test \textbar \%\_\textcircumflex \texttilde \$\#\textbraceleft \textbraceright \textpm \copyright \registered ¶\textdegree <>\& 123]], ... }} Two problems still occur. The "%"-sign in (ctx)lua (text is ignored afterwords) and the significant spaces in the tex part (which are eaten up when printed). I tried it with a modified catcodetable, but no success (ugly sideeffects). So my question is: What is the best way to 1. deal with the "%" character in ctxlua? 2. print significant spaces? My current 'solution' for 2. is writing to a tex buffer instead and then using \bgroup\obeyspaces\getbuffer[textext]\egroup If I try to use \obeyspaces in combination with the lua variable 'textext' I can no longer access the variable, as the variable is indexed by a tex macro (lets call it \FOO), which then is interpreted as whatever.["\FOO "].textext ). No solution for 1. yet. As always... any help welcome :-) Peter
On 01/14/2011 05:52 PM, Peter Rolf wrote:
What is the best way to
1. deal with the "%" character in ctxlua?
Use \startluacode .... \stopluacode instead of ctxlua.
2. print significant spaces?
My current 'solution' for 2. is writing to a tex buffer instead and then using
\bgroup\obeyspaces\getbuffer[textext]\egroup
Significant spaces are always nasty. You could convert them to "~" (of course then it does not break across lines) or "\ ". Best wishes, Taco
Thank you Taco and Hans! \startluacode works fine :-) Am 16.01.2011 08:41, schrieb Taco Hoekwater:
On 01/14/2011 05:52 PM, Peter Rolf wrote:
What is the best way to
1. deal with the "%" character in ctxlua?
Use \startluacode .... \stopluacode instead of ctxlua.
2. print significant spaces?
My current 'solution' for 2. is writing to a tex buffer instead and then using
\bgroup\obeyspaces\getbuffer[textext]\egroup
Significant spaces are always nasty. You could convert them to "~" (of course then it does not break across lines) or "\ ".
Best wishes, Taco
On 14-1-2011 5:52, Peter Rolf wrote:
problem is (aside from my limited knowledge) a XML based line of text
then process the line at the lua end where % is stil % and a space a space 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 -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Peter Rolf
-
Taco Hoekwater