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&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

Attachment: xml-and-space-preprocessor.tex
Description: Binary data

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to