diff --git a/core/modules/filters/strings.js b/core/modules/filters/strings.js index 6b76178d4..38e5be231 100644 --- a/core/modules/filters/strings.js +++ b/core/modules/filters/strings.js @@ -61,7 +61,7 @@ exports.split = makeStringBinaryOperator( ); exports["enlist-input"] = makeStringBinaryOperator( - function(a) {return $tw.utils.parseStringArray("" + a);} + function(a,o,s) {return $tw.utils.parseStringArray("" + a,(s === "raw"));} ); exports.join = makeStringReducingOperator( @@ -78,7 +78,7 @@ function makeStringBinaryOperator(fnCalc) { return function(source,operator,options) { var result = []; source(function(tiddler,title) { - Array.prototype.push.apply(result,fnCalc(title,operator.operand || "")); + Array.prototype.push.apply(result,fnCalc(title,operator.operand || "",operator.suffix || "")); }); return result; }; diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index bf537ee36..895c83ca3 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -184,6 +184,9 @@ function runTests(wiki) { it("should handle the enlist-input operator", function() { expect(wiki.filterTiddlers("[[one two three]enlist-input[]]").join(",")).toBe("one,two,three"); + expect(wiki.filterTiddlers("[[one two two three]enlist-input[]]").join(",")).toBe("one,two,three"); + expect(wiki.filterTiddlers("[[one two two three]enlist-input:dedupe[]]").join(",")).toBe("one,two,three"); + expect(wiki.filterTiddlers("[[one two two three]enlist-input:raw[]]").join(",")).toBe("one,two,two,three"); expect(wiki.filterTiddlers("[[one two three]] [[four five six]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six"); expect(wiki.filterTiddlers("[[one two three]] [[four five six]] [[seven eight]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six,seven,eight"); expect(wiki.filterTiddlers("[[]] +[enlist-input[]]").join(",")).toBe(""); diff --git a/editions/tw5.com/tiddlers/filters/enlist-input Operator.tid b/editions/tw5.com/tiddlers/filters/enlist-input Operator.tid index 3a9dd529a..a561a8e12 100644 --- a/editions/tw5.com/tiddlers/filters/enlist-input Operator.tid +++ b/editions/tw5.com/tiddlers/filters/enlist-input Operator.tid @@ -4,6 +4,8 @@ modified: 20201102221854719 op-input: a [[selection of titles|Title Selection]] op-output: the titles stored as a [[title list|Title List]] in each input title op-purpose: select titles by interpreting each input title as a [[title list|Title List]] +op-suffix: `dedupe` (the default) to remove duplicates, `raw` to leave duplicates untouched +op-suffix-name: D tags: [[Filter Operators]] [[String Operators]] [[Selection Constructors]] title: enlist-input Operator type: text/vnd.tiddlywiki diff --git a/editions/tw5.com/tiddlers/filters/examples/enlist-input Operator (Examples).tid b/editions/tw5.com/tiddlers/filters/examples/enlist-input Operator (Examples).tid index c02a85c4c..7e4eee4a7 100644 --- a/editions/tw5.com/tiddlers/filters/examples/enlist-input Operator (Examples).tid +++ b/editions/tw5.com/tiddlers/filters/examples/enlist-input Operator (Examples).tid @@ -7,4 +7,6 @@ type: text/vnd.tiddlywiki <<.operator-example 1 "[[Days of the Week]get[list]enlist-input[]]">> Contrast with: <<.operator-example 2 "[[Days of the Week]get[list]]">> <<.operator-example 3 "'HelloThere GettingStarted [[Customise TiddlyWiki]]' +[enlist-input[]]">> -Contrast with: <<.operator-example 4 "'HelloThere GettingStarted [[Customise TiddlyWiki]]'">> \ No newline at end of file +Contrast with: <<.operator-example 4 "'HelloThere GettingStarted [[Customise TiddlyWiki]]'">> +<<.operator-example 5 "'HelloThere HelloThere GettingStarted [[Customise TiddlyWiki]]' +[enlist-input:raw[]]">> +Contrast with: <<.operator-example 6 "'HelloThere HelloThere GettingStarted [[Customise TiddlyWiki]]' +[enlist-input[]]">>