mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 06:14:44 +00:00
More tests, more fixes
This commit is contained in:
parent
6c06ef316d
commit
391b1be3dc
@ -86,14 +86,16 @@ WikiTextRules.inlineCssHelper = function(w) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
WikiTextRules.applyCssHelper = function(e,styles) {
|
WikiTextRules.applyCssHelper = function(e,styles) {
|
||||||
if(!e.attributes) {
|
if(styles.length > 0) {
|
||||||
e.attributes = {};
|
if(!e.attributes) {
|
||||||
}
|
e.attributes = {};
|
||||||
if(!e.attributes.style) {
|
}
|
||||||
e.attributes.style = {};
|
if(!e.attributes.style) {
|
||||||
}
|
e.attributes.style = {};
|
||||||
for(var t=0; t< styles.length; t++) {
|
}
|
||||||
e.attributes.style[styles[t].style] = styles[t].value;
|
for(var t=0; t< styles.length; t++) {
|
||||||
|
e.attributes.style[styles[t].style] = styles[t].value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,7 +170,7 @@ WikiTextRules.rules = [
|
|||||||
var theRow = {type: "tr", children: []};
|
var theRow = {type: "tr", children: []};
|
||||||
WikiTextRules.setAttr(theRow,"className",rowCount%2 ? "oddRow" : "evenRow")
|
WikiTextRules.setAttr(theRow,"className",rowCount%2 ? "oddRow" : "evenRow")
|
||||||
rowContainer.children.push(theRow);
|
rowContainer.children.push(theRow);
|
||||||
this.rowHandler(w,theRow,prevColumns);
|
this.rowHandler(w,theRow.children,prevColumns);
|
||||||
rowCount++;
|
rowCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,11 +223,11 @@ WikiTextRules.rules = [
|
|||||||
}
|
}
|
||||||
var cell;
|
var cell;
|
||||||
if(chr == "!") {
|
if(chr == "!") {
|
||||||
cell = {type: "th", attributes: {}, children: []};
|
cell = {type: "th", children: []};
|
||||||
e.push(cell);
|
e.push(cell);
|
||||||
w.nextMatch++;
|
w.nextMatch++;
|
||||||
} else {
|
} else {
|
||||||
cell = {type: "td", attributes: {}, children: []};
|
cell = {type: "td", children: []};
|
||||||
e.push(cell);
|
e.push(cell);
|
||||||
}
|
}
|
||||||
prevCell = cell;
|
prevCell = cell;
|
||||||
@ -235,7 +237,7 @@ WikiTextRules.rules = [
|
|||||||
colSpanCount = 1;
|
colSpanCount = 1;
|
||||||
}
|
}
|
||||||
WikiTextRules.applyCssHelper(cell,styles);
|
WikiTextRules.applyCssHelper(cell,styles);
|
||||||
w.subWikifyTerm(cell,this.cellTermRegExp);
|
w.subWikifyTerm(cell.children,this.cellTermRegExp);
|
||||||
if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
|
if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
|
||||||
WikiTextRules.setAttr(cell,"align",spaceLeft ? "center" : "left");
|
WikiTextRules.setAttr(cell,"align",spaceLeft ? "center" : "left");
|
||||||
else if(spaceLeft)
|
else if(spaceLeft)
|
||||||
|
59
wikitest.js
59
wikitest.js
@ -9,7 +9,7 @@ var Tiddler = require("./js/Tiddler.js").Tiddler,
|
|||||||
util = require("util");
|
util = require("util");
|
||||||
|
|
||||||
var wikiTest = function(spec) {
|
var wikiTest = function(spec) {
|
||||||
// console.error(util.inspect(spec,false,99));
|
//console.error(util.inspect(spec,false,99));
|
||||||
var t,
|
var t,
|
||||||
store = new TiddlyWiki(),
|
store = new TiddlyWiki(),
|
||||||
w;
|
w;
|
||||||
@ -42,7 +42,9 @@ wikiTest(
|
|||||||
{ title: 'ThirdTiddler',
|
{ title: 'ThirdTiddler',
|
||||||
text: 'An explicit link [[Fourth Tiddler]] and [[a pretty link|Fourth Tiddler]]' },
|
text: 'An explicit link [[Fourth Tiddler]] and [[a pretty link|Fourth Tiddler]]' },
|
||||||
{ title: 'Fourth Tiddler',
|
{ title: 'Fourth Tiddler',
|
||||||
text: 'An image [img[Something.jpg]]' } ],
|
text: 'An image [img[Something.jpg]]' },
|
||||||
|
{ title: 'Fifth Tiddler',
|
||||||
|
text: '|A caption above the table|c\n| Left | Middle | Right |h\n|North West|North|North East|\n|West|Here|East|\n|South West|South|South East|' } ],
|
||||||
tests:
|
tests:
|
||||||
[ { tiddler: 'FirstTiddler',
|
[ { tiddler: 'FirstTiddler',
|
||||||
output:
|
output:
|
||||||
@ -100,5 +102,56 @@ wikiTest(
|
|||||||
[ { type: 'text', value: 'An image ' },
|
[ { type: 'text', value: 'An image ' },
|
||||||
{ type: 'img', attributes: { src: 'Something.jpg' } } ],
|
{ type: 'img', attributes: { src: 'Something.jpg' } } ],
|
||||||
html: 'An image <img src="Something.jpg" />',
|
html: 'An image <img src="Something.jpg" />',
|
||||||
plain: 'An image ' } } ] }
|
plain: 'An image ' } },
|
||||||
|
{ tiddler: 'Fifth Tiddler',
|
||||||
|
output:
|
||||||
|
{ tree:
|
||||||
|
[ { type: 'table',
|
||||||
|
attributes: { className: 'twtable' },
|
||||||
|
children:
|
||||||
|
[ { type: 'caption',
|
||||||
|
children: [ { type: 'text', value: 'A caption above the table' } ],
|
||||||
|
attributes: { align: 'top' } },
|
||||||
|
{ type: 'thead',
|
||||||
|
children:
|
||||||
|
[ { type: 'tr',
|
||||||
|
children:
|
||||||
|
[ { type: 'td',
|
||||||
|
children: [ { type: 'text', value: 'Left' } ],
|
||||||
|
attributes: { align: 'center' } },
|
||||||
|
{ type: 'td',
|
||||||
|
children: [ { type: 'text', value: 'Middle' } ],
|
||||||
|
attributes: { align: 'center' } },
|
||||||
|
{ type: 'td',
|
||||||
|
children: [ { type: 'text', value: 'Right' } ],
|
||||||
|
attributes: { align: 'center' } } ],
|
||||||
|
attributes: { className: 'evenRow' } } ],
|
||||||
|
attributes: {} },
|
||||||
|
{ type: 'tbody',
|
||||||
|
children:
|
||||||
|
[ { type: 'tr',
|
||||||
|
children:
|
||||||
|
[ { type: 'td',
|
||||||
|
children: [ { type: 'text', value: 'North West' } ] },
|
||||||
|
{ type: 'td', children: [ { type: 'text', value: 'North' } ] },
|
||||||
|
{ type: 'td',
|
||||||
|
children: [ { type: 'text', value: 'North East' } ] } ],
|
||||||
|
attributes: { className: 'oddRow' } },
|
||||||
|
{ type: 'tr',
|
||||||
|
children:
|
||||||
|
[ { type: 'td', children: [ { type: 'text', value: 'West' } ] },
|
||||||
|
{ type: 'td', children: [ { type: 'text', value: 'Here' } ] },
|
||||||
|
{ type: 'td', children: [ { type: 'text', value: 'East' } ] } ],
|
||||||
|
attributes: { className: 'evenRow' } },
|
||||||
|
{ type: 'tr',
|
||||||
|
children:
|
||||||
|
[ { type: 'td',
|
||||||
|
children: [ { type: 'text', value: 'South West' } ] },
|
||||||
|
{ type: 'td', children: [ { type: 'text', value: 'South' } ] },
|
||||||
|
{ type: 'td',
|
||||||
|
children: [ { type: 'text', value: 'South East' } ] } ],
|
||||||
|
attributes: { className: 'oddRow' } } ],
|
||||||
|
attributes: {} } ] } ],
|
||||||
|
html: '<table className="twtable"><caption align="top">A caption above the table</caption><thead><tr className="evenRow"><td align="center">Left</td><td align="center">Middle</td><td align="center">Right</td></tr></thead><tbody><tr className="oddRow"><td>North West</td><td>North</td><td>North East</td></tr><tr className="evenRow"><td>West</td><td>Here</td><td>East</td></tr><tr className="oddRow"><td>South West</td><td>South</td><td>South East</td></tr></tbody></table>',
|
||||||
|
plain: 'A caption above the tableLeftMiddleRightNorth WestNorthNorth EastWestHereEastSouth WestSouthSouth East' } } ] }
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user