1
0
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:
Jeremy Ruston 2011-12-06 10:40:49 +00:00
parent 5297fa690d
commit ad26dd6be3
4 changed files with 19 additions and 16 deletions

View File

@ -57,12 +57,12 @@ utils.convertFromYYYYMMDDHHMMSSMMM = function(d)
// Convert & to "&amp;", < to "&lt;", > to "&gt;" and " to "&quot;" // Convert & to "&amp;", < to "&lt;", > to "&gt;" and " to "&quot;"
utils.htmlEncode = function(s) utils.htmlEncode = function(s)
{ {
return s.replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;"); return s.toString().replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;").replace(/\"/mg,"&quot;");
}; };
// Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to " // Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to "
utils.htmlDecode = function(s) utils.htmlDecode = function(s)
{ {
return s.replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&"); return s.toString().replace(/&lt;/mg,"<").replace(/&gt;/mg,">").replace(/&quot;/mg,"\"").replace(/&amp;/mg,"&");
}; };

View File

@ -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":

View File

@ -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++) {

View File

@ -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: