Make table cells at least 3 char long

This commit is contained in:
Laurent Cozic 2018-05-21 23:55:53 +01:00
parent 90cff86ac0
commit 36179a8394
2 changed files with 4 additions and 1 deletions

View File

@ -7,6 +7,7 @@ This is a fork of the original [turndown-plugin-gfm](https://github.com/domchris
- Always render tables even if 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.
- Table cells are at least three characters long (padded with spaces) so that they render correctly in GFM-compliant renderers.
## Installation

View File

@ -99,7 +99,9 @@ function cell (content, node) {
var index = indexOf.call(node.parentNode.childNodes, node)
var prefix = ' '
if (index === 0) prefix = '| '
return prefix + content.trim().replace(/[\n\r]/g, "<br>") + ' |'
let filteredContent = content.trim().replace(/[\n\r]/g, "<br>");
while (filteredContent.length < 3) filteredContent += ' ';
return prefix + filteredContent + ' |'
}
function nodeContainsTable(node) {