From thurston at eml.cc Thu Nov 21 12:34:24 2024 From: thurston at eml.cc (Toby Thurston) Date: Thu, 21 Nov 2024 11:34:24 +0000 Subject: [metapost] "TEX(char 13)" in luamplib / plain MP Message-ID: <7701457C-7740-4771-971B-46138C3A3617@eml.cc> Recently I was trying to solve a puzzling error message that someone asked about on TeX.SE, and I came across another minor difference between plain MP and luamplib. If you run this trivial program through plain MP > input TEX > show TEX(char 13); > end. you get this in the log file > >> Edge structure at line 2: > setbounds path: > (0,0)..controls (0,0) and (0,0) > ..(0,0)..controls (0,0) and (0,0) > ..(0,0)..controls (0,0) and (0,0) > ..(0,0)..controls (0,0) and (0,0) > ..cycle > end of setbounds > End edges which shows that TEX() has returned a expression as expected (even though the picture is blank). But if I run the equivalent programme through `lualatex` > \documentclass{standalone} > \usepackage{luamplib} > \begin{document} > \begin{mplibcode} > show TEX(char 13); > \end{mplibcode} > \end{document} I get an error like this: > mplib warning: error in script: ...texlive/2024/texmf-dist/tex/luatex/luamplib/luamplib.lua:390: attempt to index a nil value (local 'box') and in the log I get > >> vacuous > (luamplib) on input line 6 > ! Missing } inserted. > > } > l.6 \end{mplibcode} > > ? which suggests that TEX() has returned a expression instead of a . The original context was that the person who asked the TeX.SE question was getting an error from an MP example of mine that included the line label(char 13 infont "eurm10", z0); which is ok in plain mpost because "eurm10" does have a valid char at position 13 (a gamma), but the questioner was trying to run the example through luamplib with `\mplibtextextlabel{enable}` so the `infont` trick meant that the line was interpreted as label(TEX(char 13), z0); which generated the errors above. I think it would be nice if the luamplib version of the TEX() macro always returned a even if it is empty. T. From nomosnomos at gmail.com Fri Nov 22 03:02:57 2024 From: nomosnomos at gmail.com (Dohyun Kim) Date: Fri, 22 Nov 2024 11:02:57 +0900 Subject: [metapost] "TEX(char 13)" in luamplib / plain MP In-Reply-To: <7701457C-7740-4771-971B-46138C3A3617@eml.cc> References: <7701457C-7740-4771-971B-46138C3A3617@eml.cc> Message-ID: Thanks for the report. char 13 is an end-of-line character. TeX will remove the remaining part after that character to the end of the line. So, the closing brace of an hbox has also been removed, raising a TeX error. I will suppress the TeX error and return a picture made by null hbox. 2024? 11? 21? (?) ?? 8:34, Toby Thurston ?? ??: > > Recently I was trying to solve a puzzling error message that someone asked about on TeX.SE, and I came across another minor difference between plain MP and luamplib. > > If you run this trivial program through plain MP > > > input TEX > > show TEX(char 13); > > end. > > you get this in the log file > > > >> Edge structure at line 2: > > setbounds path: > > (0,0)..controls (0,0) and (0,0) > > ..(0,0)..controls (0,0) and (0,0) > > ..(0,0)..controls (0,0) and (0,0) > > ..(0,0)..controls (0,0) and (0,0) > > ..cycle > > end of setbounds > > End edges > > > which shows that TEX() has returned a expression as expected (even though the picture is blank). > > But if I run the equivalent programme through `lualatex` > > > \documentclass{standalone} > > \usepackage{luamplib} > > \begin{document} > > \begin{mplibcode} > > show TEX(char 13); > > \end{mplibcode} > > \end{document} > > > I get an error like this: > > > mplib warning: error in script: ...texlive/2024/texmf-dist/tex/luatex/luamplib/luamplib.lua:390: attempt to index a nil value (local 'box') > > and in the log I get > > > >> vacuous > > (luamplib) on input line 6 > > ! Missing } inserted. > > > > } > > l.6 \end{mplibcode} > > > > ? > > > which suggests that TEX() has returned a expression instead of a . > > The original context was that the person who asked the TeX.SE question was getting an error from an MP example of mine that > included the line > > label(char 13 infont "eurm10", z0); > > which is ok in plain mpost because "eurm10" does have a valid char at position 13 (a gamma), but the questioner was > trying to run the example through luamplib with `\mplibtextextlabel{enable}` so the `infont` trick meant that the line > was interpreted as > > label(TEX(char 13), z0); > > which generated the errors above. > > I think it would be nice if the luamplib version of the TEX() macro always returned a even if it is empty. > > T. > > > > > -- > http://tug.org/metapost/ -- Dohyun Kim Seoul, Republic of Korea