horizontal rule

This commit is contained in:
Estevão Soares dos Santos 2022-05-07 19:11:50 +01:00
parent 9a66e63952
commit 1dcaa4490e

View File

@ -21,20 +21,34 @@ showdown.subParser('makehtml.horizontalRule', function (text, options, globals)
text = startEvent.output; text = startEvent.output;
const rgx1 = /^ {0,2}( ?-){3,}[ \t]*$/gm; // parses: --- and - - -
text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, function (wholeMatch) { const rgx1 = /^ {0,3}( ?-){3,}[ \t]*$/gm;
text = text.replace(rgx1, function (wholeMatch) {
return parse(rgx1, wholeMatch); return parse(rgx1, wholeMatch);
}); });
// parses: -\t-\t-
const rgx2 = /^ {0,2}( ?\*){3,}[ \t]*$/gm; const rgx2 = /^ {0,3}(\t?-){3,}[ \t]*$/gm;
text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, function (wholeMatch) { text = text.replace(rgx2, function (wholeMatch) {
return parse(rgx2, wholeMatch); return parse(rgx2, wholeMatch);
}); });
const rgx3 = /^ {0,2}( ?\*){3,}[ \t]*$/gm; const rgx3 = /^ {0,3}( ?\*){3,}[ \t]*$/gm;
text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, function (wholeMatch) { text = text.replace(rgx3, function (wholeMatch) {
return parse(rgx3, 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); let afterEvent = new showdown.Event('makehtml.horizontalRule.onEnd', text);
afterEvent afterEvent