Hi Misterel85,
This behaviour is found
in https://tiddlywiki.com/#%24%3A%2Fcore%2Fmodules%2Fwidgets%2Ftransclude.js
```
/*\
title: $:/core/modules/widgets/transclude.js
type: application/javascript
module-type: widget
Transclude widget \*/
...
var parser = this.wiki.parseTextReference( this.transcludeTitle,
this.transcludeField, this.transcludeIndex, { parseAsInline: parseAsInline,
subTiddler: this.transcludeSubTiddler })
...
```
And we can lookup the `wiki.parseTextReference` method
here: https://tiddlywiki.com/#%24%3A%2Fcore%2Fmodules%2Fwiki.js
and see that it uses the `parseText' method. This means we actually need to
look at the *$:/core/modules/parsers/wikiparser/wikiparser.js* module,
where we find:
```
/*
Push a text widget onto an array, respecting the configTrimWhiteSpace
setting
*/
WikiParser.prototype.pushTextWidget = function(array,text) {
if(this.configTrimWhiteSpace) {
text = $tw.utils.trim(text);
}
if(text) {
array.push({type: "text", text: text});
}
};
```
Now we are getting somewhere. Searching the system tiddler for
*configTrimWhiteSpace* gives us
*$:/core/modules/parsers/wikiparser/rules/whitespace.js*
Where we see the 2 pragma defined as:
```
\whitespace trim
\whitespace notrim
```
AHA!
Now we know that if we put the "pragma" of `\whitespace notrim` at the very
beginning of any Tiddler's text field, then all parsers in that tiddler
will not trim whitespace when parsing text.
Try *\whitespace notrim* before your other wikitext.
Best,
Joshua Fontany
On Saturday, August 14, 2021 at 1:28:56 PM UTC-7 Misterel85 wrote:
> How can I prevent TW from trimming leading space in field transclusion?
>
> When transcludings two fields one after the other, for instance:
>
> `<$transclude field="foo" /><$transclude field="bar" />`
>
> if the value of field "bar" starts with a space, that space is
> automatically removed in the transclusion.
>
> In this example the successive transclusions of:
>
> "foo"=> "This is foo"
> "bar"=> " and this is bar."
>
> render as:
>
> "This is fooand this is bar."
>
> Inserting a trailing space in "foo" or a ` ` between the two
> transclusions is not an option for me.
> Placing a ` ` at the beginning of the value in the second transcluded
> field works, but that's a bit of a hassle with multiple transclusions.
>
> Why does TW behave so and what is needed to achieve the result I am
> looking for (a kind of 'untrim' operator)?
>
> Sorry if that question seems trivial or was already asked before.
>
> -Stéphane L.
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/a77cfb02-7841-438f-89fa-463643fe2a8bn%40googlegroups.com.