mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-02 12:19:11 +00:00
Fix for Paul's concerns
This commit is contained in:
parent
917865c393
commit
9fee9b1043
@ -18,11 +18,11 @@ exports.types = {block: true};
|
|||||||
exports.init = function(parser) {
|
exports.init = function(parser) {
|
||||||
this.parser = parser;
|
this.parser = parser;
|
||||||
// Regexp to match
|
// Regexp to match
|
||||||
this.matchRegExp = /^\|(?:[^\n]*)\|(?:[fhck]?)\r?\n/mg;
|
this.matchRegExp = /^\|(?:[^\n]*)\|(?:[fhck]?)\r?(?:\n|$)/mg;
|
||||||
};
|
};
|
||||||
|
|
||||||
var processRow = function(prevColumns) {
|
var processRow = function(prevColumns) {
|
||||||
var cellRegExp = /(?:\|([^\n\|]*)\|)|(\|[fhck]?\r?\n)/mg,
|
var cellRegExp = /(?:\|([^\n\|]*)\|)|(\|[fhck]?\r?(?:\n|$))/mg,
|
||||||
cellTermRegExp = /((?:\x20*)\|)/mg,
|
cellTermRegExp = /((?:\x20*)\|)/mg,
|
||||||
tree = [],
|
tree = [],
|
||||||
col = 0,
|
col = 0,
|
||||||
@ -61,9 +61,9 @@ var processRow = function(prevColumns) {
|
|||||||
} else if(cellMatch[2]) {
|
} else if(cellMatch[2]) {
|
||||||
// End of row
|
// End of row
|
||||||
if(prevCell && colSpanCount > 1) {
|
if(prevCell && colSpanCount > 1) {
|
||||||
try {
|
if(prevCell.attributes && prevCell.attributes && prevCell.attributes.colspan) {
|
||||||
colSpanCount += prevCell.attributes.colspan.value;
|
colSpanCount += prevCell.attributes.colspan.value;
|
||||||
} catch (e) {
|
} else {
|
||||||
colSpanCount -= 1;
|
colSpanCount -= 1;
|
||||||
}
|
}
|
||||||
$tw.utils.addAttributeToParseTreeNode(prevCell,"colspan",colSpanCount);
|
$tw.utils.addAttributeToParseTreeNode(prevCell,"colspan",colSpanCount);
|
||||||
@ -74,18 +74,17 @@ var processRow = function(prevColumns) {
|
|||||||
// For ordinary cells, step beyond the opening `|`
|
// For ordinary cells, step beyond the opening `|`
|
||||||
this.parser.pos++;
|
this.parser.pos++;
|
||||||
// Look for a space at the start of the cell
|
// Look for a space at the start of the cell
|
||||||
var spaceLeft = false,
|
var spaceLeft = false;
|
||||||
chr = this.parser.source.substr(this.parser.pos,1);
|
|
||||||
var vAlign = null;
|
var vAlign = null;
|
||||||
if (chr === "^") {
|
if(this.parser.source.substr(this.parser.pos).search(/^\^([^\^]|\^\^)/) === 0) {
|
||||||
vAlign = "top";
|
vAlign = "top";
|
||||||
} else if(chr === ",") {
|
} else if(this.parser.source.substr(this.parser.pos).search(/^,([^,]|,,)/) === 0) {
|
||||||
vAlign = "bottom";
|
vAlign = "bottom";
|
||||||
}
|
}
|
||||||
if(vAlign) {
|
if(vAlign) {
|
||||||
this.parser.pos++;
|
this.parser.pos++;
|
||||||
chr = this.parser.source.substr(this.parser.pos,1);
|
|
||||||
}
|
}
|
||||||
|
var chr = this.parser.source.substr(this.parser.pos,1);
|
||||||
while(chr === " ") {
|
while(chr === " ") {
|
||||||
spaceLeft = true;
|
spaceLeft = true;
|
||||||
this.parser.pos++;
|
this.parser.pos++;
|
||||||
@ -132,8 +131,8 @@ var processRow = function(prevColumns) {
|
|||||||
exports.parse = function() {
|
exports.parse = function() {
|
||||||
var rowContainerTypes = {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
|
var rowContainerTypes = {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
|
||||||
table = {type: "element", tag: "table", children: []},
|
table = {type: "element", tag: "table", children: []},
|
||||||
rowRegExp = /^\|([^\n]*)\|([fhck]?)\r?\n/mg,
|
rowRegExp = /^\|([^\n]*)\|([fhck]?)\r?(?:\n|$)/mg,
|
||||||
rowTermRegExp = /(\|(?:[fhck]?)\r?\n)/mg,
|
rowTermRegExp = /(\|(?:[fhck]?)\r?(?:\n|$))/mg,
|
||||||
prevColumns = [],
|
prevColumns = [],
|
||||||
currRowType,
|
currRowType,
|
||||||
rowContainer,
|
rowContainer,
|
||||||
@ -149,7 +148,7 @@ exports.parse = function() {
|
|||||||
this.parser.pos = rowMatch.index + rowMatch[0].length;
|
this.parser.pos = rowMatch.index + rowMatch[0].length;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, create a new row if this one is of a different type
|
// Otherwise, create a new row if this one is of a different type
|
||||||
if(rowType != currRowType) {
|
if(rowType !== currRowType) {
|
||||||
rowContainer = {type: "element", tag: rowContainerTypes[rowType], children: []};
|
rowContainer = {type: "element", tag: rowContainerTypes[rowType], children: []};
|
||||||
table.children.push(rowContainer);
|
table.children.push(rowContainer);
|
||||||
currRowType = rowType;
|
currRowType = rowType;
|
||||||
|
Loading…
Reference in New Issue
Block a user