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:
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&amp;nbsp;m 6000&amp;nbsp;m 6000&amp;nbsp;m 6000&amp;nbsp;m average.</p>
</document>
\stopbuffer

\startluacode
function lxml.preprocessor(data)
    -- data = string.gsub(data, "&amp;nbsp;", "~")
    -- replacement nbsp invisible in luacode
    data = string.gsub(data, "&amp;nbsp;", " ")
    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