olsak / OpTeX

OpTeX - LuaTeX format with extended Plain TeX macros
http://petr.olsak.net/optex/
35 stars 13 forks source link

Problem with \code and optex-tricks.html#inttinoval #99

Closed robertbachmann closed 2 years ago

robertbachmann commented 2 years ago

Using the following TeX adapted from http://petr.olsak.net/optex/optex-tricks.html#inttinoval

% !TeX program = optex
\fontfam[lm]

\def\_printinverbatim#1{%
    \leavevmode\global\setbox1000=\hbox{#1}%
     \inoval{\ht0=1.35ex \dp0=.15ex \box1000}}
\verbchar`

`C:\bootmgr` vs \code{C:\\bootmgr} 

\bye

I get this result:

image

I tried to debug the issue myself, it seems to be related to \_escapechar in \code<SPACE> Using this adaptation I get the expected result (both "C:\bootmgr" in Ovals) however I'm not sure if my solution is 100% correct.

\_protected\_sdef{_code }#1{{\_escapechar=-1 \_ttfont \_the\_everyintt \_relax
\_edef\_tmpc{\_detokenize{#1}}\_escapechar=92
\_printinverbatim{\_tmpc}
}}
olsak commented 2 years ago

It seems that there was a bug in \optdef definition (\optdef'ed macros were dependent on \ecsapechar). I tried to fix this in my last commit. Thank you for noticing.

robertbachmann commented 2 years ago

works now. Thanks!