Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (counter + node.value.length < max_length) {
counter += node.value.length;
return node;
}
const nb_addable = max_length - counter;
counter = max_length;
return Object.assign({}, node, {
value: node.value.substr(0, nb_addable) + "…",
});
});
remove(truncated_tree, (node) => {
return typeof node.type === "undefined";
});
if (images_counter > 0 && toString(truncated_tree).trim().length === 0) {
return "<p><i>" + placeholder_image_text + "</i></p>";
}
return toHtml(truncated_tree);
}
inBetween.length && inBetween.forEach(n => {
if (!blockquoteNode && n.type === 'blockquote') {
blockquoteNode = n
} else {
metaNodes.push(n)
}
})
if (blockquoteNode) {
meta.description = childrenToHtml(blockquoteNode.children)
}
meta.meta = childrenToHtml(metaNodes)
remove(ast, heading1.node)
remove(ast, inBetween)
return ast
}
() => tree => {
remove(tree, 'import');
},
],
const valuesFromNodes = (tree: any) => (first: number, last: number) => {
const values = []
if (first !== last) {
for (let i = last; i >= first; i--) {
const found = tree.children[i]
if (found.children && found.children.length > 0) {
values.push(...found.children.map((child: any) => child.value))
}
if (found.value && found.value.length > 0) {
values.push(found.value)
}
if (i !== first) remove(tree, found)
}
}
return values
}
const metaNodes = []
inBetween.length && inBetween.forEach(n => {
if (!blockquoteNode && n.type === 'blockquote') {
blockquoteNode = n
} else {
metaNodes.push(n)
}
})
if (blockquoteNode) {
meta.description = childrenToHtml(blockquoteNode.children)
}
meta.meta = childrenToHtml(metaNodes)
remove(ast, heading1.node)
remove(ast, inBetween)
return ast
}