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:
parent
5297fa690d
commit
ad26dd6be3
@ -57,12 +57,12 @@ utils.convertFromYYYYMMDDHHMMSSMMM = function(d)
|
||||
// Convert & to "&", < to "<", > to ">" and " to """
|
||||
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 "
|
||||
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++) {
|
||||
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":
|
||||
|
@ -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++) {
|
||||
|
21
wikitest.js
21
wikitest.js
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user