1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +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;"
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 "
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++) {
switch(tree[t].type) {
case "text":
output.push(utils.htmlEncode(tree[t].value);
output.push(utils.htmlEncode(tree[t].value));
break;
case "br":
case "img":

View File

@ -67,10 +67,10 @@ WikiTextRules.inlineCssHelper = function(w) {
while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
var s,v;
if(lookaheadMatch[1]) {
s = lookaheadMatch[1].unDash();
s = lookaheadMatch[1];
v = lookaheadMatch[2];
} else {
s = lookaheadMatch[3].unDash();
s = lookaheadMatch[3];
v = lookaheadMatch[4];
}
if(s=="bgcolor")
@ -86,10 +86,10 @@ WikiTextRules.inlineCssHelper = function(w) {
};
WikiTextRules.applyCssHelper = function(e,styles) {
if(!"attributes" in e) {
if(!e.attributes) {
e.attributes = {};
}
if(!"styles" in e.attributes) {
if(!e.attributes.style) {
e.attributes.style = {};
}
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:
[ { 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',
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',
@ -44,14 +44,17 @@ wikiTest({ tiddlers:
[ { tiddler: 'FirstTiddler',
output:
[ { type: 'text', value: 'This is the ' },
{ type: 'strong',
children: [ { type: 'text', value: 'text' } ] },
{ type: 'text',
value: ' of the first tiddler, with a link to the ' },
{ type: 'a',
children: [ { type: 'text', value: 'SecondTiddler' } ],
attributes: {href: 'SecondTiddler', className: 'tiddlyLink' } },
{ type: 'text', value: ', too.' } ] },
{ type: 'strong',
children: [ { type: 'text', value: 'text' } ] },
{ type: 'text', value: ' of the first tiddler, with a ' },
{ type: 'span',
children: [ { type: 'text', value: 'link' } ],
attributes: { style: { 'font-size': '8em', color: 'red' } } },
{ type: 'text', value: ' to the ' },
{ type: 'a',
children: [ { type: 'text', value: 'SecondTiddler' } ],
attributes: { href: 'SecondTiddler', className: 'tiddlyLink' } },
{ type: 'text', value: ', too.' } ] },
{ tiddler: 'SecondTiddler',
output:
[ { type: 'h2',