From 7af39b57f04bc2033916fe1faa51764ee354f570 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 21 May 2018 23:42:02 +0100 Subject: [PATCH] Replace newlines inside table cells so that resulting markdown is valid --- README.md | 1 + publish.sh | 3 +++ src/tables.js | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 publish.sh diff --git a/README.md b/README.md index c05a4f57c..f712bd65e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ This is a fork of the original [turndown-plugin-gfm](https://github.com/domchris - Always render tables even they don't have a header. - Don't render the border of tables that contain other tables (frequent for websites that do the layout using tables). Only render the inner tables, if any, and if they also don't contain other tables. +- Replace newlines (`\n`) with `
` inside table cells so that multi-line content is displayed correctly as Markdown. ## Installation diff --git a/publish.sh b/publish.sh new file mode 100644 index 000000000..b6b7faee6 --- /dev/null +++ b/publish.sh @@ -0,0 +1,3 @@ +#!/bin/bash +npm version patch +npm publish \ No newline at end of file diff --git a/src/tables.js b/src/tables.js index 7e9820319..8b782dc72 100644 --- a/src/tables.js +++ b/src/tables.js @@ -99,7 +99,7 @@ function cell (content, node) { var index = indexOf.call(node.parentNode.childNodes, node) var prefix = ' ' if (index === 0) prefix = '| ' - return prefix + content + ' |' + return prefix + content.trim().replace(/[\n\r]/g, "
") + ' |' } function nodeContainsTable(node) {