Skip to content

Build your personal knowledge base with Trilium Notes

Replace newlines inside table cells so that resulting markdown is valid

Laurent Cozic7af39b57f04b
diff --git a/README.md b/README.md
index c05a4f57c8..f712bd65ee 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 `<br>` 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 0000000000..b6b7faee62
--- /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 7e98203199..8b782dc72e 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, "<br>") + ' |'
}
function nodeContainsTable(node) {