From e850d48fc3a6b87f3e35c02d50437efcd6e41af9 Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Tue, 11 Oct 2022 20:07:26 +0530 Subject: [PATCH] Fix #898, #897 --- src/util/markdown.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/util/markdown.js b/src/util/markdown.js index c6c1a490..411eec37 100644 --- a/src/util/markdown.js +++ b/src/util/markdown.js @@ -86,7 +86,8 @@ const plainRules = { }, paragraph: { ...defaultRules.paragraph, - plain: (node, output, state) => `${output(node.content, state)}\n\n`, + match: blockRegex(/^((?:[^\n]|\n(?! *\n))+)(?:\n *)+\n/), + plain: (node, output, state) => `${output(node.content, state)}\n`, html: (node, output, state) => htmlTag('p', output(node.content, state)), }, escape: { @@ -101,9 +102,7 @@ const plainRules = { text: { ...defaultRules.text, match: anyScopeRegex(/^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff]| *\n|\w+:\S|$)/), - plain: (node, _, state) => (state.kind === 'edit' - ? node.content.replace(/(\*|_|!\[|\[|\|\||\$\$?)/g, '\\$1') - : node.content), + plain: (node) => node.content, }, }; @@ -138,7 +137,15 @@ const markdownRules = { }, blockQuote: { ...defaultRules.blockQuote, - plain: (node, output, state) => `> ${output(node.content, state).trim().replace(/\n/g, '\n> ')}\n\n`, + match: blockRegex(/^( *>[^\n]+(\n *>+[^\n]+)*\n?)+/), + parse: (capture, parse, state) => { + const content = capture[0].replace(/^ *> ?/gm, ''); + return { + content: parse(`${content}\n`, state), // TODO: remove /n after fixing paragraph + }; + }, + plain: (node, output, state) => `> ${output(node.content, state).trim().replace(/\n/g, '\n> ')}`, + html: (node, output, state) => htmlTag('blockquote', output(node.content, state)), }, list: { ...defaultRules.list,