[texhax] [solved] Question about cwebmac.tex
Igor Liferenko
igor.liferenko at gmail.com
Sun Feb 14 15:04:57 CET 2016
Hi all,
Previous solution fails on outlines which have [ ] characters. The
example is hamdance.w from DEK's example programs.
\luaescapestring must be used.
Moreover, since \luaescapestring is a TeX construct, we may use
expansion features with it in a natural way.
Then the \pdfoutline with \expandafter becomes this:
\pdfoutline goto num \the\toksA
{\directlua{toutf16(string.gsub("\expandafter\expandafter\expandafter\luaescapestring\expandafter{\the\toksE}",string.char(92),""))}}}
Also use \luaescapestring in the other \pdfoutline:
\pdfoutline goto num #3 count -\expnumber{chunk#2.#3}
{\directlua{toutf16(string.gsub("\luaescapestring{#5}",string.char(92),""))}}
All backslashes are removed with string.gsub (because special
characters are converted by `toutf16'), otherwise they will appear in
the outlines.
The new functionality is fully analogous to original cwebmac.tex
I'm not sure whether \expandafter is necessary in original cwebmac.tex
(I haven't found no example which makes evident that \the\toksE may
contain expandable token - maybe \expandafter has been used because it
is a general rule to use \expandafter with \the), but this
\expandafter will not do no harm anyway - so use it, just to be safe.
Best,
Igor
More information about the texhax
mailing list