From 45b0966013c760abab5b3f7faea0e59af2ca5619 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 17 Apr 2014 16:50:54 +0100 Subject: [PATCH] Support the image widget in markdown --- plugins/tiddlywiki/markdown/wrapper.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/tiddlywiki/markdown/wrapper.js b/plugins/tiddlywiki/markdown/wrapper.js index 0cbe0dd54..4827ac34f 100644 --- a/plugins/tiddlywiki/markdown/wrapper.js +++ b/plugins/tiddlywiki/markdown/wrapper.js @@ -33,6 +33,18 @@ function transformNode(node) { }); } widget.children = transformNodes(node.slice(p++)); + // Massage images into the image widget + if(widget.tag === "img") { + widget.tag = "$image"; + if(widget.attributes.alt) { + widget.attributes.tooltip = widget.attributes.alt; + delete widget.attributes.alt; + } + if(widget.attributes.src) { + widget.attributes.source = widget.attributes.src; + delete widget.attributes.src; + } + } return widget; } else { return {type: "text", text: node};