2016-09-22 19:18:12 +03:00
|
|
|
/*
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
2021-07-01 22:33:25 +03:00
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
2016-09-22 19:18:12 +03:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-11-21 14:24:59 +03:00
|
|
|
import "./@types/commonmark"; // import better types than @types/commonmark
|
2021-01-27 16:06:59 +03:00
|
|
|
import * as commonmark from "commonmark";
|
2021-07-01 22:33:25 +03:00
|
|
|
import { escape } from "lodash";
|
2021-11-30 21:09:05 +03:00
|
|
|
import { logger } from "matrix-js-sdk/src/logger";
|
2021-12-09 12:10:23 +03:00
|
|
|
|
2021-12-03 17:00:56 +03:00
|
|
|
import { linkify } from "./linkify-matrix";
|
2017-02-02 17:17:07 +03:00
|
|
|
|
2023-07-06 01:00:27 +03:00
|
|
|
const ALLOWED_HTML_TAGS = ["sub", "sup", "del", "u", "br", "br/"];
|
2017-02-02 17:17:07 +03:00
|
|
|
|
|
|
|
// These types of node are definitely text
|
|
|
|
const TEXT_NODES = ["text", "softbreak", "linebreak", "paragraph", "document"];
|
|
|
|
|
2021-07-01 23:31:17 +03:00
|
|
|
function isAllowedHtmlTag(node: commonmark.Node): boolean {
|
2023-04-17 10:41:51 +03:00
|
|
|
if (!node.literal) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node.literal.match('^<((div|span) data-mx-maths="[^"]*"|/(div|span))>$') != null) {
|
2020-10-14 11:35:57 +03:00
|
|
|
return true;
|
2020-09-22 00:02:19 +03:00
|
|
|
}
|
|
|
|
|
2023-07-06 01:00:27 +03:00
|
|
|
// Regex won't work for tags with attrs, but the tags we allow
|
|
|
|
// shouldn't really have any anyway.
|
2017-02-02 17:17:07 +03:00
|
|
|
const matches = /^<\/?(.*)>$/.exec(node.literal);
|
|
|
|
if (matches && matches.length == 2) {
|
|
|
|
const tag = matches[1];
|
|
|
|
return ALLOWED_HTML_TAGS.indexOf(tag) > -1;
|
|
|
|
}
|
2020-10-14 11:35:57 +03:00
|
|
|
|
2017-02-02 17:17:07 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns true if the parse output containing the node
|
|
|
|
* comprises multiple block level elements (ie. lines),
|
|
|
|
* or false if it is only a single line.
|
|
|
|
*/
|
2021-07-01 23:31:17 +03:00
|
|
|
function isMultiLine(node: commonmark.Node): boolean {
|
2017-10-11 19:56:17 +03:00
|
|
|
let par = node;
|
2017-02-02 17:17:07 +03:00
|
|
|
while (par.parent) {
|
|
|
|
par = par.parent;
|
|
|
|
}
|
|
|
|
return par.firstChild != par.lastChild;
|
|
|
|
}
|
2016-09-22 19:18:12 +03:00
|
|
|
|
2023-01-12 16:25:14 +03:00
|
|
|
function getTextUntilEndOrLinebreak(node: commonmark.Node): string {
|
2023-04-17 10:41:51 +03:00
|
|
|
let currentNode: commonmark.Node | null = node;
|
2021-11-30 21:09:05 +03:00
|
|
|
let text = "";
|
2023-04-17 10:41:51 +03:00
|
|
|
while (currentNode && currentNode.type !== "softbreak" && currentNode.type !== "linebreak") {
|
2021-11-30 21:09:05 +03:00
|
|
|
const { literal, type } = currentNode;
|
|
|
|
if (type === "text" && literal) {
|
|
|
|
let n = 0;
|
|
|
|
let char = literal[n];
|
|
|
|
while (char !== " " && char !== null && n <= literal.length) {
|
|
|
|
if (char === " ") {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (char) {
|
|
|
|
text += char;
|
|
|
|
}
|
|
|
|
n += 1;
|
|
|
|
char = literal[n];
|
|
|
|
}
|
|
|
|
if (char === " ") {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentNode = currentNode.next;
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2021-12-02 13:56:23 +03:00
|
|
|
const formattingChangesByNodeType = {
|
|
|
|
emph: "_",
|
|
|
|
strong: "__",
|
|
|
|
};
|
|
|
|
|
2022-11-14 12:52:42 +03:00
|
|
|
/**
|
|
|
|
* Returns the literal of a node an all child nodes.
|
|
|
|
*/
|
|
|
|
const innerNodeLiteral = (node: commonmark.Node): string => {
|
|
|
|
let literal = "";
|
|
|
|
|
|
|
|
const walker = node.walker();
|
2023-04-17 10:41:51 +03:00
|
|
|
let step: commonmark.NodeWalkingStep | null;
|
2022-11-14 12:52:42 +03:00
|
|
|
|
|
|
|
while ((step = walker.next())) {
|
|
|
|
const currentNode = step.node;
|
|
|
|
const currentNodeLiteral = currentNode.literal;
|
|
|
|
if (step.entering && currentNode.type === "text" && currentNodeLiteral) {
|
|
|
|
literal += currentNodeLiteral;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return literal;
|
|
|
|
};
|
|
|
|
|
2023-08-17 19:37:19 +03:00
|
|
|
const emptyItemWithNoSiblings = (node: commonmark.Node): boolean => {
|
|
|
|
return !node.prev && !node.next && !node.firstChild;
|
|
|
|
};
|
|
|
|
|
2016-09-22 19:18:12 +03:00
|
|
|
/**
|
2017-02-02 14:27:07 +03:00
|
|
|
* Class that wraps commonmark, adding the ability to see whether
|
2016-09-22 19:18:12 +03:00
|
|
|
* a given message actually uses any markdown syntax or whether
|
|
|
|
* it's plain text.
|
|
|
|
*/
|
|
|
|
export default class Markdown {
|
2021-07-01 22:33:25 +03:00
|
|
|
private input: string;
|
2021-07-01 23:31:17 +03:00
|
|
|
private parsed: commonmark.Node;
|
2021-07-01 22:33:25 +03:00
|
|
|
|
2022-12-16 15:29:59 +03:00
|
|
|
public constructor(input: string) {
|
2018-01-07 23:30:18 +03:00
|
|
|
this.input = input;
|
2017-02-02 14:34:39 +03:00
|
|
|
|
|
|
|
const parser = new commonmark.Parser();
|
|
|
|
this.parsed = parser.parse(this.input);
|
2021-11-30 21:09:05 +03:00
|
|
|
this.parsed = this.repairLinks(this.parsed);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is modifying the parsed AST in such a way that links are always
|
|
|
|
* properly linkified instead of sometimes being wrongly emphasised in case
|
|
|
|
* if you were to write a link like the example below:
|
|
|
|
* https://my_weird-link_domain.domain.com
|
|
|
|
* ^ this link would be parsed to something like this:
|
|
|
|
* <a href="https://my">https://my</a><b>weird-link</b><a href="https://domain.domain.com">domain.domain.com</a>
|
|
|
|
* This method makes it so the link gets properly modified to a version where it is
|
|
|
|
* not emphasised until it actually ends.
|
|
|
|
* See: https://github.com/vector-im/element-web/issues/4674
|
|
|
|
* @param parsed
|
|
|
|
*/
|
2023-01-12 16:25:14 +03:00
|
|
|
private repairLinks(parsed: commonmark.Node): commonmark.Node {
|
2021-11-30 21:09:05 +03:00
|
|
|
const walker = parsed.walker();
|
2023-02-13 20:01:43 +03:00
|
|
|
let event: commonmark.NodeWalkingStep | null = null;
|
2021-11-30 21:09:05 +03:00
|
|
|
let text = "";
|
|
|
|
let isInPara = false;
|
|
|
|
let previousNode: commonmark.Node | null = null;
|
2021-12-02 13:56:23 +03:00
|
|
|
let shouldUnlinkFormattingNode = false;
|
2021-11-30 21:09:05 +03:00
|
|
|
while ((event = walker.next())) {
|
|
|
|
const { node } = event;
|
|
|
|
if (node.type === "paragraph") {
|
|
|
|
if (event.entering) {
|
|
|
|
isInPara = true;
|
|
|
|
} else {
|
|
|
|
isInPara = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isInPara) {
|
|
|
|
// Clear saved string when line ends
|
|
|
|
if (
|
|
|
|
node.type === "softbreak" ||
|
|
|
|
node.type === "linebreak" ||
|
|
|
|
// Also start calculating the text from the beginning on any spaces
|
|
|
|
(node.type === "text" && node.literal === " ")
|
|
|
|
) {
|
|
|
|
text = "";
|
2022-03-08 16:12:36 +03:00
|
|
|
continue;
|
2021-11-30 21:09:05 +03:00
|
|
|
}
|
2022-03-08 16:12:36 +03:00
|
|
|
|
|
|
|
// Break up text nodes on spaces, so that we don't shoot past them without resetting
|
2023-04-17 10:41:51 +03:00
|
|
|
if (node.type === "text" && node.literal) {
|
2022-03-08 16:12:36 +03:00
|
|
|
const [thisPart, ...nextParts] = node.literal.split(/( )/);
|
|
|
|
node.literal = thisPart;
|
|
|
|
text += thisPart;
|
|
|
|
|
|
|
|
// Add the remaining parts as siblings
|
|
|
|
nextParts.reverse().forEach((part) => {
|
|
|
|
if (part) {
|
|
|
|
const nextNode = new commonmark.Node("text");
|
|
|
|
nextNode.literal = part;
|
|
|
|
node.insertAfter(nextNode);
|
|
|
|
// Make the iterator aware of the newly inserted node
|
|
|
|
walker.resumeAt(nextNode, true);
|
|
|
|
}
|
|
|
|
});
|
2021-11-30 21:09:05 +03:00
|
|
|
}
|
2022-03-08 16:12:36 +03:00
|
|
|
|
2021-11-30 21:09:05 +03:00
|
|
|
// We should not do this if previous node was not a textnode, as we can't combine it then.
|
2023-04-17 10:41:51 +03:00
|
|
|
if ((node.type === "emph" || node.type === "strong") && previousNode?.type === "text") {
|
2021-11-30 21:09:05 +03:00
|
|
|
if (event.entering) {
|
|
|
|
const foundLinks = linkify.find(text);
|
|
|
|
for (const { value } of foundLinks) {
|
2023-04-17 10:41:51 +03:00
|
|
|
if (node?.firstChild?.literal) {
|
2021-11-30 21:09:05 +03:00
|
|
|
/**
|
|
|
|
* NOTE: This technically should unlink the emph node and create LINK nodes instead, adding all the next elements as siblings
|
|
|
|
* but this solution seems to work well and is hopefully slightly easier to understand too
|
|
|
|
*/
|
2021-12-02 13:56:23 +03:00
|
|
|
const format = formattingChangesByNodeType[node.type];
|
2022-11-14 12:52:42 +03:00
|
|
|
const nonEmphasizedText = `${format}${innerNodeLiteral(node)}${format}`;
|
2021-11-30 21:09:05 +03:00
|
|
|
const f = getTextUntilEndOrLinebreak(node);
|
|
|
|
const newText = value + nonEmphasizedText + f;
|
|
|
|
const newLinks = linkify.find(newText);
|
|
|
|
// Should always find only one link here, if it finds more it means that the algorithm is broken
|
|
|
|
if (newLinks.length === 1) {
|
|
|
|
const emphasisTextNode = new commonmark.Node("text");
|
|
|
|
emphasisTextNode.literal = nonEmphasizedText;
|
|
|
|
previousNode.insertAfter(emphasisTextNode);
|
|
|
|
node.firstChild.literal = "";
|
|
|
|
event = node.walker().next();
|
2023-04-17 10:41:51 +03:00
|
|
|
if (event) {
|
|
|
|
// Remove `em` opening and closing nodes
|
|
|
|
node.unlink();
|
|
|
|
previousNode.insertAfter(event.node);
|
|
|
|
shouldUnlinkFormattingNode = true;
|
|
|
|
}
|
2021-11-30 21:09:05 +03:00
|
|
|
} else {
|
|
|
|
logger.error(
|
|
|
|
"Markdown links escaping found too many links for following text: ",
|
|
|
|
text,
|
|
|
|
);
|
|
|
|
logger.error(
|
|
|
|
"Markdown links escaping found too many links for modified text: ",
|
|
|
|
newText,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2021-12-02 13:56:23 +03:00
|
|
|
if (shouldUnlinkFormattingNode) {
|
2021-11-30 21:09:05 +03:00
|
|
|
node.unlink();
|
2021-12-02 13:56:23 +03:00
|
|
|
shouldUnlinkFormattingNode = false;
|
2021-11-30 21:09:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
previousNode = node;
|
|
|
|
}
|
|
|
|
return parsed;
|
2016-09-22 19:18:12 +03:00
|
|
|
}
|
|
|
|
|
2022-12-16 15:29:59 +03:00
|
|
|
public isPlainText(): boolean {
|
2017-02-02 17:17:07 +03:00
|
|
|
const walker = this.parsed.walker();
|
2023-04-17 10:41:51 +03:00
|
|
|
let ev: commonmark.NodeWalkingStep | null;
|
2023-08-17 19:37:19 +03:00
|
|
|
|
2022-01-10 15:57:20 +03:00
|
|
|
while ((ev = walker.next())) {
|
2017-02-02 17:17:07 +03:00
|
|
|
const node = ev.node;
|
2023-08-17 19:37:19 +03:00
|
|
|
|
2017-02-02 17:17:07 +03:00
|
|
|
if (TEXT_NODES.indexOf(node.type) > -1) {
|
|
|
|
// definitely text
|
|
|
|
continue;
|
2023-08-17 19:37:19 +03:00
|
|
|
} else if (node.type == "list" || node.type == "item") {
|
|
|
|
// Special handling for inputs like `+`, `*`, `-` and `2021.` which
|
|
|
|
// would otherwise be treated as a list of a single empty item.
|
|
|
|
// See https://github.com/vector-im/element-web/issues/7631
|
|
|
|
if (node.type == "list" && node.firstChild && emptyItemWithNoSiblings(node.firstChild)) {
|
|
|
|
// A list with a single empty item is treated as plain text.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (node.type == "item" && emptyItemWithNoSiblings(node)) {
|
|
|
|
// An empty list item with no sibling items is treated as plain text.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Everything else is actual lists and therefore not plaintext.
|
|
|
|
return false;
|
2017-02-02 17:17:07 +03:00
|
|
|
} else if (node.type == "html_inline" || node.type == "html_block") {
|
|
|
|
// if it's an allowed html tag, we need to render it and therefore
|
|
|
|
// we will need to use HTML. If it's not allowed, it's not HTML since
|
|
|
|
// we'll just be treating it as text.
|
2021-07-01 22:33:25 +03:00
|
|
|
if (isAllowedHtmlTag(node)) {
|
2017-02-02 17:17:07 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-22 19:18:12 +03:00
|
|
|
}
|
2017-02-02 17:17:07 +03:00
|
|
|
return true;
|
2016-09-22 19:18:12 +03:00
|
|
|
}
|
|
|
|
|
2022-12-16 15:29:59 +03:00
|
|
|
public toHTML({ externalLinks = false } = {}): string {
|
2017-02-17 21:06:00 +03:00
|
|
|
const renderer = new commonmark.HtmlRenderer({
|
|
|
|
safe: false,
|
|
|
|
|
|
|
|
// Set soft breaks to hard HTML breaks: commonmark
|
|
|
|
// puts softbreaks in for multiple lines in a blockquote,
|
|
|
|
// so if these are just newline characters then the
|
|
|
|
// block quote ends up all on one line
|
2020-08-03 18:02:26 +03:00
|
|
|
// (https://github.com/vector-im/element-web/issues/3154)
|
2017-02-17 21:06:00 +03:00
|
|
|
softbreak: "<br />",
|
2022-11-21 14:24:59 +03:00
|
|
|
});
|
2018-05-23 16:00:54 +03:00
|
|
|
|
|
|
|
// Trying to strip out the wrapping <p/> causes a lot more complication
|
|
|
|
// than it's worth, i think. For instance, this code will go and strip
|
|
|
|
// out any <p/> tag (no matter where it is in the tree) which doesn't
|
|
|
|
// contain \n's.
|
|
|
|
// On the flip side, <p/>s are quite opionated and restricted on where
|
|
|
|
// you can nest them.
|
|
|
|
//
|
|
|
|
// Let's try sending with <p/>s anyway for now, though.
|
2021-07-01 22:33:25 +03:00
|
|
|
const realParagraph = renderer.paragraph;
|
2021-07-02 01:02:51 +03:00
|
|
|
renderer.paragraph = function (node: commonmark.Node, entering: boolean) {
|
2017-01-18 21:29:11 +03:00
|
|
|
// If there is only one top level node, just return the
|
|
|
|
// bare text: it's a single line of text and so should be
|
|
|
|
// 'inline', rather than unnecessarily wrapped in its own
|
|
|
|
// p tag. If, however, we have multiple nodes, each gets
|
|
|
|
// its own p tag to keep them as separate paragraphs.
|
2021-11-30 13:25:08 +03:00
|
|
|
// However, if it's a blockquote, adds a p tag anyway
|
|
|
|
// in order to avoid deviation to commonmark and unexpected
|
|
|
|
// results when parsing the formatted HTML.
|
2023-02-13 20:01:43 +03:00
|
|
|
if (node.parent?.type === "block_quote" || isMultiLine(node)) {
|
2021-07-01 22:33:25 +03:00
|
|
|
realParagraph.call(this, node, entering);
|
2017-01-18 00:20:05 +03:00
|
|
|
}
|
2017-01-20 17:22:27 +03:00
|
|
|
};
|
2018-07-18 12:48:54 +03:00
|
|
|
|
2020-01-23 01:08:34 +03:00
|
|
|
renderer.link = function (node, entering) {
|
|
|
|
const attrs = this.attrs(node);
|
2023-04-17 10:41:51 +03:00
|
|
|
if (entering && node.destination) {
|
2020-01-23 01:08:34 +03:00
|
|
|
attrs.push(["href", this.esc(node.destination)]);
|
|
|
|
if (node.title) {
|
|
|
|
attrs.push(["title", this.esc(node.title)]);
|
|
|
|
}
|
|
|
|
// Modified link behaviour to treat them all as external and
|
|
|
|
// thus opening in a new tab.
|
|
|
|
if (externalLinks) {
|
|
|
|
attrs.push(["target", "_blank"]);
|
2020-02-24 01:14:29 +03:00
|
|
|
attrs.push(["rel", "noreferrer noopener"]);
|
2020-01-23 01:08:34 +03:00
|
|
|
}
|
|
|
|
this.tag("a", attrs);
|
|
|
|
} else {
|
|
|
|
this.tag("/a");
|
|
|
|
}
|
|
|
|
};
|
2017-01-18 00:20:05 +03:00
|
|
|
|
2021-07-02 01:02:51 +03:00
|
|
|
renderer.html_inline = function (node: commonmark.Node) {
|
2023-04-17 10:41:51 +03:00
|
|
|
if (node.literal) {
|
|
|
|
if (isAllowedHtmlTag(node)) {
|
|
|
|
this.lit(node.literal);
|
|
|
|
} else {
|
|
|
|
this.lit(escape(node.literal));
|
|
|
|
}
|
2021-07-01 22:33:25 +03:00
|
|
|
}
|
|
|
|
};
|
2018-07-18 12:48:54 +03:00
|
|
|
|
2021-07-02 01:02:51 +03:00
|
|
|
renderer.html_block = function (node: commonmark.Node) {
|
2021-07-01 22:33:25 +03:00
|
|
|
/*
|
2017-02-02 17:17:07 +03:00
|
|
|
// as with `paragraph`, we only insert line breaks
|
|
|
|
// if there are multiple lines in the markdown.
|
|
|
|
const isMultiLine = is_multi_line(node);
|
|
|
|
if (isMultiLine) this.cr();
|
2021-07-01 22:33:25 +03:00
|
|
|
*/
|
|
|
|
renderer.html_inline(node);
|
|
|
|
/*
|
2017-02-02 17:17:07 +03:00
|
|
|
if (isMultiLine) this.cr();
|
2021-07-01 22:33:25 +03:00
|
|
|
*/
|
2017-10-11 19:56:17 +03:00
|
|
|
};
|
2017-02-02 17:17:07 +03:00
|
|
|
|
2017-02-02 14:45:21 +03:00
|
|
|
return renderer.render(this.parsed);
|
2017-01-18 21:29:11 +03:00
|
|
|
}
|
|
|
|
|
2017-02-02 14:27:07 +03:00
|
|
|
/*
|
2017-02-02 17:17:07 +03:00
|
|
|
* Render the markdown message to plain text. That is, essentially
|
2017-02-02 14:27:07 +03:00
|
|
|
* just remove any backslashes escaping what would otherwise be
|
|
|
|
* markdown syntax
|
2020-08-03 18:02:26 +03:00
|
|
|
* (to fix https://github.com/vector-im/element-web/issues/2870).
|
2018-05-12 22:04:58 +03:00
|
|
|
*
|
|
|
|
* N.B. this does **NOT** render arbitrary MD to plain text - only MD
|
|
|
|
* which has no formatting. Otherwise it emits HTML(!).
|
2017-02-02 14:27:07 +03:00
|
|
|
*/
|
2022-12-16 15:29:59 +03:00
|
|
|
public toPlaintext(): string {
|
2022-11-21 14:24:59 +03:00
|
|
|
const renderer = new commonmark.HtmlRenderer({ safe: false });
|
2017-01-18 21:29:11 +03:00
|
|
|
|
2021-07-02 01:02:51 +03:00
|
|
|
renderer.paragraph = function (node: commonmark.Node, entering: boolean) {
|
2017-02-02 17:17:07 +03:00
|
|
|
// as with toHTML, only append lines to paragraphs if there are
|
|
|
|
// multiple paragraphs
|
2021-07-01 22:33:25 +03:00
|
|
|
if (isMultiLine(node)) {
|
2017-02-02 17:17:07 +03:00
|
|
|
if (!entering && node.next) {
|
2017-01-18 21:29:11 +03:00
|
|
|
this.lit("\n\n");
|
2016-12-02 21:58:35 +03:00
|
|
|
}
|
2016-09-22 20:57:46 +03:00
|
|
|
}
|
2017-01-20 17:22:27 +03:00
|
|
|
};
|
2018-05-23 05:43:40 +03:00
|
|
|
|
2021-07-02 01:02:51 +03:00
|
|
|
renderer.html_block = function (node: commonmark.Node) {
|
2023-04-17 10:41:51 +03:00
|
|
|
if (node.literal) this.lit(node.literal);
|
2021-07-01 22:33:25 +03:00
|
|
|
if (isMultiLine(node) && node.next) this.lit("\n\n");
|
2017-10-11 19:56:17 +03:00
|
|
|
};
|
2016-09-22 20:57:46 +03:00
|
|
|
|
2017-02-02 14:45:21 +03:00
|
|
|
return renderer.render(this.parsed);
|
2016-09-22 19:18:12 +03:00
|
|
|
}
|
|
|
|
}
|