From 3b35d7dfe41618d8ba53c67253bcfec309fecfde Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sun, 17 Nov 2013 21:53:12 +0000 Subject: [PATCH] Fixed problem with greedy regexp for macrocalls It was preventing this from working: ``` <><><><> ``` --- core/modules/parsers/wikiparser/rules/macrocallblock.js | 2 +- editions/test/tiddlers/tests/test-wikitext-parser.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/parsers/wikiparser/rules/macrocallblock.js b/core/modules/parsers/wikiparser/rules/macrocallblock.js index 3287fe589..2a23ed777 100644 --- a/core/modules/parsers/wikiparser/rules/macrocallblock.js +++ b/core/modules/parsers/wikiparser/rules/macrocallblock.js @@ -22,7 +22,7 @@ exports.types = {block: true}; exports.init = function(parser) { this.parser = parser; // Regexp to match - this.matchRegExp = /<<([^\s>]+)\s*([\s\S]*?)>>(?:\r?\n|$)/mg; + this.matchRegExp = /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*?)>>(?:\r?\n|$)/mg; }; /* diff --git a/editions/test/tiddlers/tests/test-wikitext-parser.js b/editions/test/tiddlers/tests/test-wikitext-parser.js index 24c399fbc..8565e196e 100644 --- a/editions/test/tiddlers/tests/test-wikitext-parser.js +++ b/editions/test/tiddlers/tests/test-wikitext-parser.js @@ -104,6 +104,15 @@ describe("WikiText parser tests", function() { }); + it("should parse macro calls", function() { + expect(parse("<><><><>")).toEqual( + + [ { type : 'element', tag : 'p', children : [ { type : 'macrocall', name : 'john', params : [ ] }, { type : 'macrocall', name : 'paul', params : [ ] }, { type : 'macrocall', name : 'george', params : [ ] }, { type : 'macrocall', name : 'ringo', params : [ ] } ] } ] + + ); + + }); + }); })();