From 6d09b2fb9cd40a890a6b9730b23ffad3fbe57cd8 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 29 Nov 2012 17:23:46 +0000 Subject: [PATCH] Improve syntax for classed runs --- core/modules/parsers/wikitextparser/rules/list.js | 2 +- .../parsers/wikitextparser/wikitextparser.js | 13 +++++++------ core/templates/PageTemplate.tid | 2 +- editions/tw5.com/tiddlers/concepts/WikiText.tid | 6 +++--- readme.md | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/modules/parsers/wikitextparser/rules/list.js b/core/modules/parsers/wikitextparser/rules/list.js index 8b406152e..816641d09 100644 --- a/core/modules/parsers/wikitextparser/rules/list.js +++ b/core/modules/parsers/wikitextparser/rules/list.js @@ -35,7 +35,7 @@ A CSS class can be applied to a list item as follows: {{{ * List item one -*{{active}} List item two has the class `active` +*.active List item two has the class `active` * List item three }}} diff --git a/core/modules/parsers/wikitextparser/wikitextparser.js b/core/modules/parsers/wikitextparser/wikitextparser.js index dfd6395ab..a094c5451 100644 --- a/core/modules/parsers/wikitextparser/wikitextparser.js +++ b/core/modules/parsers/wikitextparser/wikitextparser.js @@ -238,20 +238,21 @@ WikiTextRenderer.prototype.parseRunTerminated = function(terminatorRegExp,option }; /* -Parse a run of text preceded by an optional class specifier `{{class}}` +Parse a run of text preceded by an optional class specifier `.classname` */ WikiTextRenderer.prototype.parseClassedRun = function(terminatorRegExp) { - var classRegExp = /\{\{([^\}]*)\}\}/mg, - className; + var classRegExp = /\.([^\s\.]+)/mg, + classNames = []; classRegExp.lastIndex = this.pos; var match = classRegExp.exec(this.source); - if(match && match.index === this.pos) { - className = match[1]; + while(match && match.index === this.pos) { this.pos = match.index + match[0].length; + classNames.push(match[1]); + var match = classRegExp.exec(this.source); } var tree = this.parseRun(terminatorRegExp); return { - "class": className, + "class": classNames.join(" "), tree: tree }; }; diff --git a/core/templates/PageTemplate.tid b/core/templates/PageTemplate.tid index 029d1db03..1c5572e72 100644 --- a/core/templates/PageTemplate.tid +++ b/core/templates/PageTemplate.tid @@ -13,7 +13,7 @@ title: $:/templates/PageTemplate * HelloThere * [[Docs]] -*{{divider-vertical}} +*.divider-vertical