mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +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) {
|
||||
if(!e.attributes) {
|
||||
e.attributes = {};
|
||||
}
|
||||
if(!e.attributes.style) {
|
||||
e.attributes.style = {};
|
||||
}
|
||||
for(var t=0; t< styles.length; t++) {
|
||||
e.attributes.style[styles[t].style] = styles[t].value;
|
||||
if(styles.length > 0) {
|
||||
if(!e.attributes) {
|
||||
e.attributes = {};
|
||||
}
|
||||
if(!e.attributes.style) {
|
||||
e.attributes.style = {};
|
||||
}
|
||||
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: []};
|
||||
WikiTextRules.setAttr(theRow,"className",rowCount%2 ? "oddRow" : "evenRow")
|
||||
rowContainer.children.push(theRow);
|
||||
this.rowHandler(w,theRow,prevColumns);
|
||||
this.rowHandler(w,theRow.children,prevColumns);
|
||||
rowCount++;
|
||||
}
|
||||
}
|
||||
@ -221,11 +223,11 @@ WikiTextRules.rules = [
|
||||
}
|
||||
var cell;
|
||||
if(chr == "!") {
|
||||
cell = {type: "th", attributes: {}, children: []};
|
||||
cell = {type: "th", children: []};
|
||||
e.push(cell);
|
||||
w.nextMatch++;
|
||||
} else {
|
||||
cell = {type: "td", attributes: {}, children: []};
|
||||
cell = {type: "td", children: []};
|
||||
e.push(cell);
|
||||
}
|
||||
prevCell = cell;
|
||||
@ -235,7 +237,7 @@ WikiTextRules.rules = [
|
||||
colSpanCount = 1;
|
||||
}
|
||||
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
|
||||
WikiTextRules.setAttr(cell,"align",spaceLeft ? "center" : "left");
|
||||
else if(spaceLeft)
|
||||
|
59
wikitest.js
59
wikitest.js
@ -9,7 +9,7 @@ var Tiddler = require("./js/Tiddler.js").Tiddler,
|
||||
util = require("util");
|
||||
|
||||
var wikiTest = function(spec) {
|
||||
// console.error(util.inspect(spec,false,99));
|
||||
//console.error(util.inspect(spec,false,99));
|
||||
var t,
|
||||
store = new TiddlyWiki(),
|
||||
w;
|
||||
@ -42,7 +42,9 @@ wikiTest(
|
||||
{ title: 'ThirdTiddler',
|
||||
text: 'An explicit link [[Fourth Tiddler]] and [[a pretty link|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:
|
||||
[ { tiddler: 'FirstTiddler',
|
||||
output:
|
||||
@ -100,5 +102,56 @@ wikiTest(
|
||||
[ { type: 'text', value: 'An image ' },
|
||||
{ type: 'img', attributes: { 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…
Reference in New Issue
Block a user