[NTG-context] Puzzle (for me)

Gerben Wierda gerben.wierda at rna.nl
Wed Apr 1 01:20:57 CEST 2020

I have a string with double quotes that needs to become a text in a box in METAPOST. METAPOST is used to create an image consisting of boxes and connections.

Basically, the approach is now something like this:

TeX: calls Lua code with \ctxlua{filename}
Lua: context.startMPpage
Lua: read XML. String in XML in filename read by Lua
  Here we know the dimensions in which the string must be typeset and wrapped around because that is also in the XML
Lua: A context() call contains METAPOST code that calls a METAPOST vardef (‘draw box’) with the string as argument
METAPOST: Draws box and call TeX to typeset string using textext(), returns picture object
TeX: Typeset string

In short:
TeX, calls
	Lua, reads XML and executes context( MP code) that gets executed on stopMPpage
		MP code calls TeX which typesets the string

But, if the string contains double quotes (”) this will fail in METAPOST because the double quotes in the string will be printed in METAPOST code that is created by Lua and thus mess up METAPOST.

So, what can I do?


More information about the ntg-context mailing list