mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-07-03 10:32:50 +00:00
Test improvements and associated bug fixes
This commit is contained in:
parent
5297fa690d
commit
ad26dd6be3
@ -57,12 +57,12 @@ utils.convertFromYYYYMMDDHHMMSSMMM = function(d)
|
|||||||
// Convert & to "&", < to "<", > to ">" and " to """
|
// Convert & to "&", < to "<", > to ">" and " to """
|
||||||
utils.htmlEncode = function(s)
|
utils.htmlEncode = function(s)
|
||||||
{
|
{
|
||||||
return s.replace(/&/mg,"&").replace(/</mg,"<").replace(/>/mg,">").replace(/\"/mg,""");
|
return s.toString().replace(/&/mg,"&").replace(/</mg,"<").replace(/>/mg,">").replace(/\"/mg,""");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert "&" to &, "<" to <, ">" to > and """ to "
|
// Convert "&" to &, "<" to <, ">" to > and """ to "
|
||||||
utils.htmlDecode = function(s)
|
utils.htmlDecode = function(s)
|
||||||
{
|
{
|
||||||
return s.replace(/</mg,"<").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&");
|
return s.toString().replace(/</mg,"<").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ WikiTextParser.prototype.renderAsHtml = function(store,title) {
|
|||||||
for(var t=0; t<tree.length; t++) {
|
for(var t=0; t<tree.length; t++) {
|
||||||
switch(tree[t].type) {
|
switch(tree[t].type) {
|
||||||
case "text":
|
case "text":
|
||||||
output.push(utils.htmlEncode(tree[t].value);
|
output.push(utils.htmlEncode(tree[t].value));
|
||||||
break;
|
break;
|
||||||
case "br":
|
case "br":
|
||||||
case "img":
|
case "img":
|
||||||
|
@ -67,10 +67,10 @@ WikiTextRules.inlineCssHelper = function(w) {
|
|||||||
while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
|
while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
|
||||||
var s,v;
|
var s,v;
|
||||||
if(lookaheadMatch[1]) {
|
if(lookaheadMatch[1]) {
|
||||||
s = lookaheadMatch[1].unDash();
|
s = lookaheadMatch[1];
|
||||||
v = lookaheadMatch[2];
|
v = lookaheadMatch[2];
|
||||||
} else {
|
} else {
|
||||||
s = lookaheadMatch[3].unDash();
|
s = lookaheadMatch[3];
|
||||||
v = lookaheadMatch[4];
|
v = lookaheadMatch[4];
|
||||||
}
|
}
|
||||||
if(s=="bgcolor")
|
if(s=="bgcolor")
|
||||||
@ -86,10 +86,10 @@ WikiTextRules.inlineCssHelper = function(w) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
WikiTextRules.applyCssHelper = function(e,styles) {
|
WikiTextRules.applyCssHelper = function(e,styles) {
|
||||||
if(!"attributes" in e) {
|
if(!e.attributes) {
|
||||||
e.attributes = {};
|
e.attributes = {};
|
||||||
}
|
}
|
||||||
if(!"styles" in e.attributes) {
|
if(!e.attributes.style) {
|
||||||
e.attributes.style = {};
|
e.attributes.style = {};
|
||||||
}
|
}
|
||||||
for(var t=0; t< styles.length; t++) {
|
for(var t=0; t< styles.length; t++) {
|
||||||
|
11
wikitest.js
11
wikitest.js
@ -33,7 +33,7 @@ console.error("%s in HTML:\n%s\nAnd in plain:\n%s",
|
|||||||
|
|
||||||
wikiTest({ tiddlers:
|
wikiTest({ tiddlers:
|
||||||
[ { title: 'FirstTiddler',
|
[ { title: 'FirstTiddler',
|
||||||
text: 'This is the \'\'text\'\' of the first tiddler, with a link to the SecondTiddler, too.' },
|
text: 'This is the \'\'text\'\' of the first tiddler, with a @@font-size:8em;color:red;link@@ to the SecondTiddler, too.' },
|
||||||
{ title: 'SecondTiddler',
|
{ title: 'SecondTiddler',
|
||||||
text: '!!Heading\nThis is the second tiddler. It has a list:\n* Item one\n* Item two\n* Item three\nAnd a <<macro invocation>>\n' },
|
text: '!!Heading\nThis is the second tiddler. It has a list:\n* Item one\n* Item two\n* Item three\nAnd a <<macro invocation>>\n' },
|
||||||
{ title: 'ThirdTiddler',
|
{ title: 'ThirdTiddler',
|
||||||
@ -46,11 +46,14 @@ wikiTest({ tiddlers:
|
|||||||
[ { type: 'text', value: 'This is the ' },
|
[ { type: 'text', value: 'This is the ' },
|
||||||
{ type: 'strong',
|
{ type: 'strong',
|
||||||
children: [ { type: 'text', value: 'text' } ] },
|
children: [ { type: 'text', value: 'text' } ] },
|
||||||
{ type: 'text',
|
{ type: 'text', value: ' of the first tiddler, with a ' },
|
||||||
value: ' of the first tiddler, with a link to the ' },
|
{ type: 'span',
|
||||||
|
children: [ { type: 'text', value: 'link' } ],
|
||||||
|
attributes: { style: { 'font-size': '8em', color: 'red' } } },
|
||||||
|
{ type: 'text', value: ' to the ' },
|
||||||
{ type: 'a',
|
{ type: 'a',
|
||||||
children: [ { type: 'text', value: 'SecondTiddler' } ],
|
children: [ { type: 'text', value: 'SecondTiddler' } ],
|
||||||
attributes: {href: 'SecondTiddler', className: 'tiddlyLink' } },
|
attributes: { href: 'SecondTiddler', className: 'tiddlyLink' } },
|
||||||
{ type: 'text', value: ', too.' } ] },
|
{ type: 'text', value: ', too.' } ] },
|
||||||
{ tiddler: 'SecondTiddler',
|
{ tiddler: 'SecondTiddler',
|
||||||
output:
|
output:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user