From 1dcaa4490e2af8ab352fa3b38efb6b9d5a76bb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Estev=C3=A3o=20Soares=20dos=20Santos?= Date: Sat, 7 May 2022 19:11:50 +0100 Subject: [PATCH] horizontal rule --- src/subParsers/makehtml/horizontalRule.js | 28 +++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/subParsers/makehtml/horizontalRule.js b/src/subParsers/makehtml/horizontalRule.js index 0c03087..c1a4513 100644 --- a/src/subParsers/makehtml/horizontalRule.js +++ b/src/subParsers/makehtml/horizontalRule.js @@ -21,20 +21,34 @@ showdown.subParser('makehtml.horizontalRule', function (text, options, globals) text = startEvent.output; - const rgx1 = /^ {0,2}( ?-){3,}[ \t]*$/gm; - text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, function (wholeMatch) { + // parses: --- and - - - + const rgx1 = /^ {0,3}( ?-){3,}[ \t]*$/gm; + text = text.replace(rgx1, function (wholeMatch) { return parse(rgx1, wholeMatch); }); - - const rgx2 = /^ {0,2}( ?\*){3,}[ \t]*$/gm; - text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, function (wholeMatch) { + // parses: -\t-\t- + const rgx2 = /^ {0,3}(\t?-){3,}[ \t]*$/gm; + text = text.replace(rgx2, function (wholeMatch) { return parse(rgx2, wholeMatch); }); - const rgx3 = /^ {0,2}( ?\*){3,}[ \t]*$/gm; - text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, function (wholeMatch) { + const rgx3 = /^ {0,3}( ?\*){3,}[ \t]*$/gm; + text = text.replace(rgx3, function (wholeMatch) { return parse(rgx3, wholeMatch); }); + const rgx4 = /^ {0,3}(\t?\*){3,}[ \t]*$/gm; + text = text.replace(rgx4, function (wholeMatch) { + return parse(rgx4, wholeMatch); + }); + + const rgx5 = /^ {0,3}( ?\*){3,}[ \t]*$/gm; + text = text.replace(rgx5, function (wholeMatch) { + return parse(rgx5, wholeMatch); + }); + const rgx6 = /^ {0,3}(\t?\*){3,}[ \t]*$/gm; + text = text.replace(rgx6, function (wholeMatch) { + return parse(rgx6, wholeMatch); + }); let afterEvent = new showdown.Event('makehtml.horizontalRule.onEnd', text); afterEvent