[NTG-context] XML, dealing with whitespace

denis.maier at unibe.ch denis.maier at unibe.ch
Mon Jan 17 10:47:17 CET 2022

Hi Wolfgang,

Von: Wolfgang Schuster <wolfgang.schuster.lists at gmail.com>
Gesendet: Samstag, 15. Januar 2022 20:28
An: mailing list for ConTeXt users <ntg-context at ntg.nl>; Denis Maier via ntg-context <ntg-context at ntg.nl>
Cc: Maier, Denis Christian (UB) <denis.maier at unibe.ch>
Betreff: Re: [NTG-context] XML, dealing with whitespace

Denis Maier via ntg-context schrieb am 15.01.2022 um 13:04:

Hi all,

I have sources that look like this:

<?xml version="1.0" encoding="UTF-8"?>
   <p>Bla Bla Bla</p>
      </underline>, Bla Bla.</p>

Typesetting this with context gives me a spurious space after the underlined Bla in italics.

There is no spurious space, the line break is just converted to a space and I see no reason why this shouldn't happen. To remove space before or after certain parts of text within a paragraph you can use the \removeunwantedspace and \ignorespaces commands.

Yes, it's absolutely true. From tex's point of view, the space is not spurious. It's absolutely adaquate to treat the newline as a space here.

As I've outlined in my original post the problem occurs because xslt adds these indentations here. FWIW, I finally found this solution, which seems has been added to xslt 3.0 (after being available as a saxon extension: there's a new attribute <suppress-indentation> on xsl:output that can be used to control this:
<This is a new property in XSLT 3.0 (it was previously available in Saxon as an extension). The value is a whitespace-separated list of element names, and it typically identifies "inline" elements that should not cause indentation; in XHTML, for example, these would be b, i, span, and the like.>

So, the solution to my problem is this:

    suppress-indentation="italic underline"


%%%% begin example
\starttexdefinition RemovePreceding #1

\starttexdefinition RemoveFollowing #1


Bla \RemovePreceding{Bla} Bla

Bla \RemoveFollowing{Bla} Bla

%%%% end example

When only  following spaces are a problem a better alternative to \ignorespace is \autoinsertnextspace which checks the following token which ensures there is space when the next character is punctuation.

%%%% begin example
\starttexdefinition Italic #1

\starttexdefinition Underbar #1


Bla Bla Bla

\Underbar{\Italic{Bla} , Bla Bla.}

%%%% end example

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220117/5f176c2f/attachment.htm>

More information about the ntg-context mailing list