mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
added image handling to tw2parser
This commit is contained in:
parent
36a7b1149f
commit
c8d9ceaf2d
11
plugins/tiddlywiki/tw2parser/image-css.tid
Normal file
11
plugins/tiddlywiki/tw2parser/image-css.tid
Normal file
@ -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;
|
||||
}
|
@ -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"
|
||||
}
|
||||
|
@ -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 {
|
||||
insertMacroCall(w,w.output,"image",imageParams);
|
||||
w.output.push({
|
||||
type: "link",
|
||||
attributes: {
|
||||
to: {type: "string", value: lookaheadMatch[5]}
|
||||
},
|
||||
children: [node]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
w.output.push(node);
|
||||
}
|
||||
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
||||
}
|
||||
}
|
||||
},
|
||||
*/
|
||||
|
||||
{
|
||||
name: "html",
|
||||
match: "<[Hh][Tt][Mm][Ll]>",
|
||||
|
Loading…
Reference in New Issue
Block a user