[texhax] Question about cwebmac.tex

Igor Liferenko igor.liferenko at gmail.com
Mon Feb 1 22:57:53 CET 2016

Hi all,

Is it possible that the following macros from cwebmac.tex makes \toksE
contain no expandable tokens at all?

    % now comes a routine to "sanitize" section names, for pdf outlines
      \let\next\makeolnexttok % default
      \else\ifx{\nxt \else\ifx}\nxt \Tnumfalse \instrfalse % skip braces
      \else\ifx$\nxt % or a $ sign
      \else\ifx^\nxt \addF^\else\ifx_\nxt \addF_% sanitize ^ and _
      \else\ifx\nxt\spacechar \addF\space
      \else\if\noexpand\nxt\relax % we have a control sequence; is it
one we know?
        \iftokprocessed\else\makeolproctokctliii % if not recognised, skip it
       \else  % we don't have a control sequence, it's an ordinary char
        \ifx/\nxt \addF{\string\/}% quote chars special to PDF with backslash
        \else\ifx(\nxt \addF{\string\(}\else\ifx)\nxt \addF{\string\)}%
        \else\ifx[\nxt \addF{\string\[}\else\ifx]\nxt \addF{\string\]}%

What should be taken into account to convert the following three
commands to \directlua so, that they will behave the same way?

    \pdfoutline goto name {NOS} count -\secno {\outsecname}

    \pdfoutline goto num \the\toksA \expandafter{\the\toksE}}

    \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}}

Using David Carlisle's example with \directlua I get \foo in both
cases - with and without using \expandafter. Why?

      function toutf16(str)
    \pdfoutline goto num 2 \expandafter{\directlua{toutf16("\the\toksE")}}
    \pdfoutline goto num 3 {\directlua{toutf16("\the\toksE")}}

Best wishes,

More information about the texhax mailing list