From 128c94804a158c11c0d24f2a5bbd023c3df13136 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 3 Mar 2012 13:35:51 +0000 Subject: [PATCH] Fixed type block bug --- js/WikiTextRules.js | 3 ++- tiddlywiki5/tiddlers/TypedBlockTests.tid | 28 ++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/js/WikiTextRules.js b/js/WikiTextRules.js index 636724516..4fe54ee19 100755 --- a/js/WikiTextRules.js +++ b/js/WikiTextRules.js @@ -400,9 +400,10 @@ var rules = [ { name: "typedBlock", match: "^\\$\\$\\$(?:.*)\\n", - lookaheadRegExp: /^\$\$\$(.*)\n((?:.|\n)*?)\$\$\$/mg, + lookaheadRegExp: /^\$\$\$(.*)\n((?:^[^\n]*\n)+?)(^\f*\$\$\$$\n?)/mg, handler: function(w) { + this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source); if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { // The wikitext parsing infrastructure is horribly unre-entrant diff --git a/tiddlywiki5/tiddlers/TypedBlockTests.tid b/tiddlywiki5/tiddlers/TypedBlockTests.tid index cd819bd11..e4b408940 100644 --- a/tiddlywiki5/tiddlers/TypedBlockTests.tid +++ b/tiddlywiki5/tiddlers/TypedBlockTests.tid @@ -1,11 +1,31 @@ title: TypedBlockTests -Here's an example of a typed block containing JavaScript source code: -$$$.js -return 2+2; +WikiText can include blocks of text that are rendered with an explicit MIME type like this: +{{{ +$$$application/javascript +//This is some JavaScript +return 2 + "one"; +$$$ +}}} +This renders as: + +$$$application/javascript +//This is some JavaScript +return 2 + "one"; $$$ -Here's an example of a typed block containing an SVG image: +It is also possible to abbreviate the MIME type to a file extension. For example: + +{{{ +$$$.svg + + + +$$$ +}}} + +This renders as: + $$$image/svg+xml