mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-26 03:27:18 +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:
parent
b54a88ce83
commit
284669544b
@ -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) {
|
||||
|
@ -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>
|
@ -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>
|
Loading…
Reference in New Issue
Block a user