diff --git a/rabbithole/core/boot.js b/rabbithole/core/boot.js index 3b0023d96..fde327573 100644 --- a/rabbithole/core/boot.js +++ b/rabbithole/core/boot.js @@ -389,7 +389,7 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/js","t match = headerCommentRegExp.exec(text); fields.text = text; if(match) { - fields = $tw.utils.parseFields(match[1],fields); + fields = $tw.utils.parseFields(match[1].split("\n\n")[0],fields); } return [fields]; } @@ -473,11 +473,16 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom"," var text = node.innerHTML, s = text.indexOf("{"), e = text.lastIndexOf("}"); - if(s !== -1 && e !== -1) { + if(node.hasAttribute("data-module") && s !== -1 && e !== -1) { text = text.substring(s+1,e-1); } - var fields = $tw.wiki.deserializeTiddlers("application/javascript",text)[0]; - fields.title = node.getAttribute("data-tiddler-title"); + var fields = {text: text}, + attributes = node.attributes; + for(var a=0; a\n"); - result.push("$tw.modules.define(\"" + tiddler.fields.title + "\",\"" + tiddler.fields["module-type"] + "\",function(module,exports,require) {"); - result.push(tiddler.fields.text); - result.push("});\n"); - result.push(""); - return result.join(""); + var attributes = { + type: "text/javascript", + "data-module": "yes" + }, // The script type is set to text/javascript for compatibility with old browsers + text = tiddler.fields.text; + text = "$tw.modules.define(\"" + tiddler.fields.title + "\",\"" + tiddler.fields["module-type"] + "\",function(module,exports,require) {" + text + "});\n"; + for(var f in tiddler.fields) { + if(f !== "text") { + attributes["data-tiddler-" + f] = tiddler.getFieldString(f); + } + } + return $tw.Tree.Element( + "script", + attributes, + [$tw.Tree.Raw(text)] + ).render("text/html"); }; exports["application/x-tiddler-html-div"] = function(tiddler) { diff --git a/rabbithole/core/tiddlywiki5.template.html.tid b/rabbithole/core/tiddlywiki5.template.html.tid index ff81714f1..bad15ed3b 100644 --- a/rabbithole/core/tiddlywiki5.template.html.tid +++ b/rabbithole/core/tiddlywiki5.template.html.tid @@ -36,16 +36,12 @@ type: text/x-tiddlywiki-html <<^"[is[tiddler]]" application/x-tiddler-html-div>> - +<<^"$:/core/bootprefix.js" application/javascript>> - +<<^"$:/core/boot.js" application/javascript>>