From 99d3d287543c84257e09e6432045dcf8ff4e40e9 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Tue, 17 Dec 2024 21:48:11 -0600 Subject: [PATCH] Correct end of match criteria for justified paragraph to account for end of stream --- shared/naturalcrit/markdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 7a5c45d99..c87121ddc 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -383,7 +383,7 @@ const justifiedParagraphs = { return src.match(/\n(?:-:|:-|-:) {1}/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const regex = /^(((:-))|((-:))|((:-:))) .+\n([^\n].*\n)*\n/ygm; + const regex = /^(((:-))|((-:))|((:-:))) .+(\n(([^\n].*\n)*(\n|$))|$)/ygm; const match = regex.exec(src); if(match?.length) { let whichJustify; @@ -396,7 +396,7 @@ const justifiedParagraphs = { length : match[whichJustify].length, text : match[0].slice(match[whichJustify].length), class : justifiedParagraphClasses[whichJustify], - tokens : this.lexer.inlineTokens(match[0].slice(match[whichJustify].length)) + tokens : this.lexer.inlineTokens(match[0].slice(match[whichJustify].length + 1)) }; } },