Try this: %\xmltexentity{nbsp}{\nobreakspace} \xmlsetentity{nbsp}{ } % U+00A0 NBSP between braces %\xmlsetentity{nbsp}{ } % U+0020 normal space between braces \startbuffer[doc] <?xml version "1.0"?> <document> <p>Temperature 20 °C 20 °C 20 °C 20 °C average.</p> <p>Altitude 6000 m 6000 m 6000 m 6000 m average.</p> </document> \stopbuffer \startluacode --[[ function lxml.preprocessor(data) -- data = string.gsub(data, " ", "~") -- replacement nbsp invisible in luacode data = string.gsub(data, " ", " ") return data end --]] \stopluacode \startxmlsetups xml:name \xmlsetsetup{\xmldocument}{*}{-} \xmlsetsetup{\xmldocument}{document|p}{xml:name:*} \stopxmlsetups \xmlregistersetup{xml:name} \startxmlsetups xml:name:document \xmlflush{#1}\par \stopxmlsetups \startxmlsetups xml:name:p \parfillskip0pt\xmlflush{#1}\par \stopxmlsetups \startTEXpage[offset=5mm,width=60mm] \xmlprocessbuffer{xml:name}{doc}{} \stopTEXpage Massi Il 21/04/21 20:17, Jano Kula ha scritto:
Dear list,
first episode of series on nbsp of XML in lmtx. Unfortunately, not that catchy as Netflix.
Used XML input has two types of non-breakable space:
* unicode character * html entitity (in fact an ugly output of HTML editor)
HTML is preprocessed with ctx preprocessor (great feature!) and substituted for unicode char nbsp or tilde.
MWE shows unichar spaces are non-breakable (see end of the first lines), however they are not stretchable (see second line of the paragraphs).
Does unicode nbsp have fixed with in ctx?
When tilde is the replacement in preprocessor (uncomment first replacement in preprocessor), xmlfush will display tilde (which is, as character, non-breakable and unstretchable, no surprise).
Why tilde is displayed?
Replacing or adding nbsp (tilde) with finalizers have different results, see next episode after this one is understood.
Thank you, Jano
MWE (rather use attached file not to loose invisible characters):
\startbuffer[doc] <?xml version "1.0"?> <document> <p>Temperature 20 °C 20 °C 20 °C 20 °C average.</p> <p>Altitude 6000 m 6000 m 6000 m 6000 m average.</p> </document> \stopbuffer
\startluacode function lxml.preprocessor(data) -- data = string.gsub(data, " ", "~") -- replacement nbsp invisible in luacode data = string.gsub(data, " ", " ") return data end \stopluacode
\startxmlsetups xml:name \xmlsetsetup{\xmldocument}{*}{-} \xmlsetsetup{\xmldocument}{document|p}{xml:name:*} \stopxmlsetups \xmlregistersetup{xml:name}
\startxmlsetups xml:name:document \xmlflush{#1}\par \stopxmlsetups
\startxmlsetups xml:name:p \parfillskip0pt\xmlflush{#1}\par \stopxmlsetups
\startTEXpage[offset=5mm,width=60mm] \xmlprocessbuffer{xml:name}{doc}{} \stopTEXpage