diff --git a/plugins/tiddlywiki/tw2parser/image-css.tid b/plugins/tiddlywiki/tw2parser/image-css.tid new file mode 100644 index 000000000..b408bea40 --- /dev/null +++ b/plugins/tiddlywiki/tw2parser/image-css.tid @@ -0,0 +1,11 @@ +tags: $:/tags/stylesheet +title: $:/plugins/tiddlywiki/tw2parser/image-css +type: text/plain + +.classic-image-left{ + float: left; +} + +.classic-image-right{ + float: right; +} diff --git a/plugins/tiddlywiki/tw2parser/plugin.info b/plugins/tiddlywiki/tw2parser/plugin.info index 3b9d10719..5c5fe493c 100644 --- a/plugins/tiddlywiki/tw2parser/plugin.info +++ b/plugins/tiddlywiki/tw2parser/plugin.info @@ -1,6 +1,8 @@ { "title": "$:/plugins/tiddlywiki/tw2parser", "description": "TiddlyWiki Classic-compatible wikitext parser", - "authors": "JeremyRuston, JeffreyWilkinson" - "core-version": ">=5.0.0" + "authors": "JeremyRuston, JeffreyWilkinson", + "version": "0.0.2-alpha-tw2parser", + "core-version": ">=5.0.15", + "plugin-type": "plugin" } diff --git a/plugins/tiddlywiki/tw2parser/wikitextrules.js b/plugins/tiddlywiki/tw2parser/wikitextrules.js index 7618d873b..d0ad4757d 100755 --- a/plugins/tiddlywiki/tw2parser/wikitextrules.js +++ b/plugins/tiddlywiki/tw2parser/wikitextrules.js @@ -491,6 +491,7 @@ var rules = [ if (name) { if (!!macroadapter.paramadapter[name]) { params=macroadapter.paramadapter[name](params); + //alert("going out as "+params); } if (!!macroadapter.namedapter[name]) { name=macroadapter.namedapter[name]; @@ -602,7 +603,7 @@ var rules = [ } }, -/* + { name: "image", match: "\\[[<>]?[Ii][Mm][Gg]\\[", @@ -610,33 +611,53 @@ var rules = [ lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg, handler: function(w) { + var node = { + type: "image", + attributes: {} + }; this.lookaheadRegExp.lastIndex = w.matchStart; var lookaheadMatch = this.lookaheadRegExp.exec(w.source), imageParams = {}, linkParams = {}; if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { if(lookaheadMatch[1]) { - imageParams.alignment = "left"; + node.attributes.class = {type: "string", value: "classic-image-left"}; } else if(lookaheadMatch[2]) { - imageParams.alignment = "right"; + node.attributes.class = {type: "string", value: "classic-image-right"}; } if(lookaheadMatch[3]) { - imageParams.text = lookaheadMatch[3]; + node.attributes.tooltip = {type: "string", value: lookaheadMatch[3]}; } - imageParams.src = lookaheadMatch[4]; + node.attributes.source = {type: "string", value: lookaheadMatch[4]}; if(lookaheadMatch[5]) { - linkParams.target = lookaheadMatch[5]; - var linkChildren = []; - insertMacroCall(w,w.output,"link",linkParams,linkChildren); - insertMacroCall(w,linkChildren,"image",imageParams); + if(isLinkExternal(lookaheadMatch[5])) { + w.output.push({ + type: "element", + tag: "a", + attributes: { + href: {type: "string", value:lookaheadMatch[5]}, + "class": {type: "string", value: "tw-tiddlylink-external"}, + target: {type: "string", value: "_blank"} + }, + children: [node] + }); + } else { + w.output.push({ + type: "link", + attributes: { + to: {type: "string", value: lookaheadMatch[5]} + }, + children: [node] + }); + } } else { - insertMacroCall(w,w.output,"image",imageParams); + w.output.push(node); } w.nextMatch = this.lookaheadRegExp.lastIndex; } } }, -*/ + { name: "html", match: "<[Hh][Tt][Mm][Ll]>",