1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-26 18:10:27 +00:00

Trim whitespace when importing variables in $importvariables (#7611)

* fix: trim whitespace when importing variables

* feat: added tests for importing variables
This commit is contained in:
Saq Imtiaz 2023-07-17 10:18:42 +02:00 committed by GitHub
parent b54a88ce83
commit 284669544b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 1 deletions

View File

@ -49,7 +49,7 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) {
this.tiddlerList = tiddlerList || this.wiki.filterTiddlers(this.filter,this);
// Accumulate the <$set> widgets from each tiddler
$tw.utils.each(this.tiddlerList,function(title) {
var parser = widgetPointer.wiki.parseTiddler(title,{parseAsInline:true});
var parser = widgetPointer.wiki.parseTiddler(title,{parseAsInline:true, configTrimWhiteSpace:true});
if(parser) {
var parseTreeNode = parser.tree[0];
while(parseTreeNode && ["setvariable","set","parameters"].indexOf(parseTreeNode.type) !== -1) {

View File

@ -0,0 +1,22 @@
title: ImportVariables/WithSetWidgets2
description: Import variables defined with a set widget without whitespace pragma
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\import Definitions
<$text text=<<one>>/>,
<$text text=<<two>>/>
+
title: Definitions
<$set name="one" value="elephant">
<$set name="two" value="giraffe">
</$set>
</$set>
+
title: ExpectedResult
<p>elephant,giraffe</p>

View File

@ -0,0 +1,29 @@
title: ImportVariables/WithSetWidgetsAndMacros
description: Import variables defined with a set widget without whitespace pragma
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\import Definitions
<$text text=<<name>>/>,
<$text text=<<address>>/>,
<$text text=<<one>>/>,
<$text text=<<two>>/>
+
title: Definitions
\define name() Bugs Bunny
\procedure address()
Bunny Hill
\end
<$set name="one" value="elephant">
<$set name="two" value="giraffe">
</$set>
</$set>
+
title: ExpectedResult
<p>Bugs Bunny,Bunny Hill,elephant,giraffe</p>