From 3dbc6ffcfb071a8d9fca9eff6fc2f953117d6a72 Mon Sep 17 00:00:00 2001 From: Alessandro Vermeulen Date: Fri, 9 Jan 2015 21:32:05 +0100 Subject: [PATCH] Added fix to prevent table rendering to be broken by alignment character ":". --- src/extensions/table.js | 12 ++++++------ test/extensions/table/basic-alignment.html | 21 +++++++++++++++++++++ test/extensions/table/basic-alignment.md | 4 ++++ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 test/extensions/table/basic-alignment.html create mode 100644 test/extensions/table/basic-alignment.md diff --git a/src/extensions/table.js b/src/extensions/table.js index faa9659..48ac3b6 100644 --- a/src/extensions/table.js +++ b/src/extensions/table.js @@ -15,7 +15,7 @@ (function(){ var table = function(converter) { - var tables = {}, style = 'text-align:left;', filter; + var tables = {}, style = 'text-align:left;', filter; tables.th = function(header){ if (header.trim() === "") { return "";} var id = header.trim().replace(/ /g, '_').toLowerCase(); @@ -54,7 +54,7 @@ out += "\n"; return out; }; - filter = function(text) { + filter = function(text) { var i=0, lines = text.split('\n'), line, hs, rows, out = []; for (i; i + + + First Header + Second Header + + + + + +

Row 1 Cell 1

+

Row 1 Cell 2

+ + + +

Row 2 Cell 1

+

Row 2 Cell 2

+ + + + diff --git a/test/extensions/table/basic-alignment.md b/test/extensions/table/basic-alignment.md new file mode 100644 index 0000000..5aa9082 --- /dev/null +++ b/test/extensions/table/basic-alignment.md @@ -0,0 +1,4 @@ +| First Header | Second Header | +| :------------ | :------------ | +| Row 1 Cell 1 | Row 1 Cell 2 | +| Row 2 Cell 1 | Row 2 Cell 2 |