\whitespace trim

Overly zealous? Expected or bug?

Same issue with…

''This'' //is// ''a'' //test// ''of'' //trim//

I have seen this in some places, but not so overtley with wikitext.

  • I suppose we don’t see this because its usualy in TiddlyWiki Script, procedures or buttons, where we just want the result without any whitespace
  • It seems like a bug, even if it was long standing.

In the following rewrite of your example the last is me using non-braking spaces to prevent it.

\whitespace trim
;This is a test of trim
# This is a <span>test</span> of trim
# This is a <b>test</b> of trim
# <b>is</b> <i>a</i> <b>test</b> <i>0f</i> <b>trim</b>
# ''This'' //is// ''a'' //test// ''of'' //trim//
# This is a&nbsp;<b>test</b>&nbsp;of trim

The action of “whitespace trim” is very specific: each text node generated during parsing has whitespace trimmed from the start and end. A text node is generated for each run of text that is not part of any other syntax. So the text nodes in your example are:

* `\nThis is a test of trim`
* `This is a `
* ` test`
* ` of trim`
* `This is a `
* `test`
* ` of trim`
* ` This`
etc

You can see the text nodes that are generated using the parse tree preview provided by the Internals plugin.

1 Like

1 Like