Skip to content

Commit

Permalink
refactor(hr): speed up hr parsing
Browse files Browse the repository at this point in the history
speed up horizontal rule parsing by simplifying the regex
  • Loading branch information
tivie committed Dec 17, 2016
1 parent f0d25b7 commit 0a856d5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/subParsers/blockGamut.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ showdown.subParser('blockGamut', function (text, options, globals) {

// Do Horizontal Rules:
var key = showdown.subParser('hashBlock')('<hr />', options, globals);
text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, key);
text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm, key);
text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm, key);
text = text.replace(/^ {0,2}( ?\* ?){3,}[ \t]*$/gm, key);
text = text.replace(/^ {0,2}( ?- ?){3,}[ \t]*$/gm, key);
text = text.replace(/^ {0,2}( ?_ ?){3,}[ \t]*$/gm, key);

text = showdown.subParser('lists')(text, options, globals);
text = showdown.subParser('codeBlocks')(text, options, globals);
Expand Down

0 comments on commit 0a856d5

Please sign in to comment.