UNPKG

html-to-article-json

Version:
20 lines (17 loc) 620 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var shouldRemoveLinebreak = function shouldRemoveLinebreak(children) { return children[children.length - 1].type === 'linebreak' && children[children.length - 2] && children[children.length - 2].type !== 'linebreak' && !isEmptyMarkNode(children[children.length - 2]); }; exports.default = function (tree) { tree.forEach(function (row) { if (row.children && shouldRemoveLinebreak(row.children)) { row.children = row.children.slice(0, -1); } }); }; function isEmptyMarkNode(node) { return node.mark && !node.content; }