From b41a1cb4de64c42e82ff396a7e7de7321080c49f Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 14 Jun 2012 18:49:51 +0100 Subject: [PATCH] Fixed problem with styled block wikitext rule --- .../newwikitextparser/rules/styleblock.js | 4 ++-- .../wikitextrules/StyleBlockWikiText.tid | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/modules/parsers/newwikitextparser/rules/styleblock.js b/core/modules/parsers/newwikitextparser/rules/styleblock.js index decc92b55..b56978dcb 100644 --- a/core/modules/parsers/newwikitextparser/rules/styleblock.js +++ b/core/modules/parsers/newwikitextparser/rules/styleblock.js @@ -39,9 +39,9 @@ exports.parse = function(match,isBlock) { // Look for the first style specifier reStyleSpecififer.lastIndex = this.pos; match = reStyleSpecififer.exec(this.source); - while(match) { + while(match && match.index === this.pos) { // Save the style specified - styles[match[1].trim()] = match[2].trim(); + styles[match[1]] = match[2].trim(); // Look to see if there is a further style specifier this.pos = match.index + match[0].length; reStyleSpecififer.lastIndex = this.pos; diff --git a/tw5.com/tiddlers/wikitextrules/StyleBlockWikiText.tid b/tw5.com/tiddlers/wikitextrules/StyleBlockWikiText.tid index 6791af3fc..2a9023713 100644 --- a/tw5.com/tiddlers/wikitextrules/StyleBlockWikiText.tid +++ b/tw5.com/tiddlers/wikitextrules/StyleBlockWikiText.tid @@ -19,3 +19,23 @@ The HTML looks like this: {{{

This is in red!

}}} + +Note that the style block doesn't generate any HTML elements itself, but instead causes the styles to be applied to all of the elements contained within the style block. This means that you can assign styles to elements generated from WikiText. For example, here is a list with some additional styles applied: + +{{{ +@@background-color:#00f +* First item +* Second item +* Third item +@@ +}}} + +The generated HTML is: + +{{{ + +}}} +