diff --git a/lib/converters.js b/lib/converters.js index c8addc9..97af2ee 100644 --- a/lib/converters.js +++ b/lib/converters.js @@ -231,6 +231,7 @@ converters.table = (input, json2md) => { .map(cell => json2md(cell)) .map(cell => parseTextFormat(cell)) .map(cell => cell.replace(/([^\\])\|/, "$1\\|")) + .map(cell => cell.trim()) .map(fill_tbody_cell) .join(" | ") + " |" ).join("\n"); diff --git a/test/index.js b/test/index.js index 52c8e24..7155978 100644 --- a/test/index.js +++ b/test/index.js @@ -356,6 +356,25 @@ tester.describe("json2md", test => { cb(); }) + test.it("should support tables with links", function(cb) { + test.expect(json2md({ + table: { + headers: ["a", "b"], + rows: [ + { + a: { + link: { + title: "aTitle", + source: "http://www.example.com" + } + }, + b: "col2" + } + ], + } + })).toBe('| a | b |\n| --- | --- |\n| [aTitle](http://www.example.com) | col2 |\n'); + cb(); + }) }); tester.describe("json2md.async", test => {