From ce8cc7607fee3d6161c10044d83d8cdaa87eabba Mon Sep 17 00:00:00 2001 From: Stephan Hradek Date: Mon, 30 Dec 2013 13:44:32 +0100 Subject: [PATCH] =?UTF-8?q?changed=20to=20conform=20to=20Jeremy's=20standa?= =?UTF-8?q?rds=20-=20sorry=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/modules/parsers/wikiparser/rules/table.js | 6 +----- core/modules/utils/parsetree.js | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/table.js b/core/modules/parsers/wikiparser/rules/table.js index 973cea457..be37f4091 100644 --- a/core/modules/parsers/wikiparser/rules/table.js +++ b/core/modules/parsers/wikiparser/rules/table.js @@ -52,11 +52,7 @@ var processRow = function(prevColumns) { // Move to just before the `|` terminating the cell this.parser.pos = cellRegExp.lastIndex - 1; } else if(cellMatch[1] === "<" && prevCell) { - try { - colSpanCount = 1+prevCell.attributes.colspan.value; - } catch (e) { - colSpanCount = 2; - } + colSpanCount = 1+$tw.utils.getAttributeValueFromParseTreeNode(prevCell, "colspan", 1); $tw.utils.addAttributeToParseTreeNode(prevCell,"colspan",colSpanCount); colSpanCount = 1; // Move to just before the `|` terminating the cell diff --git a/core/modules/utils/parsetree.js b/core/modules/utils/parsetree.js index 6e8ad27c6..d21659c22 100644 --- a/core/modules/utils/parsetree.js +++ b/core/modules/utils/parsetree.js @@ -19,6 +19,13 @@ exports.addAttributeToParseTreeNode = function(node,name,value) { } }; +exports.getAttributeValueFromParseTreeNode = function(node,name,defaultValue) { + if(node.type === "element" && node.attributes && node.attributes[name] && node.attributes[name].value != undefined) { + return node.attributes[name].value; + } + return defaultValue; +}; + exports.addClassToParseTreeNode = function(node,classString) { var classes = []; if(node.type === "element") {