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",
|
"title": "$:/plugins/tiddlywiki/tw2parser",
|
||||||
"description": "TiddlyWiki Classic-compatible wikitext parser",
|
"description": "TiddlyWiki Classic-compatible wikitext parser",
|
||||||
"authors": "JeremyRuston, JeffreyWilkinson"
|
"authors": "JeremyRuston, JeffreyWilkinson",
|
||||||
"core-version": ">=5.0.0"
|
"version": "0.0.2-alpha-tw2parser",
|
||||||
|
"core-version": ">=5.0.15",
|
||||||
|
"plugin-type": "plugin"
|
||||||
}
|
}
|
||||||
|
@ -491,6 +491,7 @@ var rules = [
|
|||||||
if (name) {
|
if (name) {
|
||||||
if (!!macroadapter.paramadapter[name]) {
|
if (!!macroadapter.paramadapter[name]) {
|
||||||
params=macroadapter.paramadapter[name](params);
|
params=macroadapter.paramadapter[name](params);
|
||||||
|
//alert("going out as "+params);
|
||||||
}
|
}
|
||||||
if (!!macroadapter.namedapter[name]) {
|
if (!!macroadapter.namedapter[name]) {
|
||||||
name=macroadapter.namedapter[name];
|
name=macroadapter.namedapter[name];
|
||||||
@ -602,7 +603,7 @@ var rules = [
|
|||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/*
|
|
||||||
{
|
{
|
||||||
name: "image",
|
name: "image",
|
||||||
match: "\\[[<>]?[Ii][Mm][Gg]\\[",
|
match: "\\[[<>]?[Ii][Mm][Gg]\\[",
|
||||||
@ -610,33 +611,53 @@ var rules = [
|
|||||||
lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
|
lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
|
||||||
handler: function(w)
|
handler: function(w)
|
||||||
{
|
{
|
||||||
|
var node = {
|
||||||
|
type: "image",
|
||||||
|
attributes: {}
|
||||||
|
};
|
||||||
this.lookaheadRegExp.lastIndex = w.matchStart;
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
||||||
var lookaheadMatch = this.lookaheadRegExp.exec(w.source),
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source),
|
||||||
imageParams = {},
|
imageParams = {},
|
||||||
linkParams = {};
|
linkParams = {};
|
||||||
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
||||||
if(lookaheadMatch[1]) {
|
if(lookaheadMatch[1]) {
|
||||||
imageParams.alignment = "left";
|
node.attributes.class = {type: "string", value: "classic-image-left"};
|
||||||
} else if(lookaheadMatch[2]) {
|
} else if(lookaheadMatch[2]) {
|
||||||
imageParams.alignment = "right";
|
node.attributes.class = {type: "string", value: "classic-image-right"};
|
||||||
}
|
}
|
||||||
if(lookaheadMatch[3]) {
|
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]) {
|
if(lookaheadMatch[5]) {
|
||||||
linkParams.target = lookaheadMatch[5];
|
if(isLinkExternal(lookaheadMatch[5])) {
|
||||||
var linkChildren = [];
|
w.output.push({
|
||||||
insertMacroCall(w,w.output,"link",linkParams,linkChildren);
|
type: "element",
|
||||||
insertMacroCall(w,linkChildren,"image",imageParams);
|
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 {
|
} else {
|
||||||
insertMacroCall(w,w.output,"image",imageParams);
|
w.output.push(node);
|
||||||
}
|
}
|
||||||
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
name: "html",
|
name: "html",
|
||||||
match: "<[Hh][Tt][Mm][Ll]>",
|
match: "<[Hh][Tt][Mm][Ll]>",
|
||||||
|
Loading…
Reference in New Issue
Block a user