diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-01-09 23:08:34 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-01-09 23:17:00 -0800 |
commit | 589d607197bb21648ca8bb564b822560676e8edf (patch) | |
tree | 0008fa5fe856641b6918ad7af12a2ce17f3f168c /js | |
parent | 1640365a8ba0c414e03922796dd5a0ed0e600bda (diff) |
Put backtick regexes in variables.
Diffstat (limited to 'js')
-rw-r--r-- | js/lib/inlines.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/js/lib/inlines.js b/js/lib/inlines.js index 0b40dfd..2c4fd13 100644 --- a/js/lib/inlines.js +++ b/js/lib/inlines.js @@ -65,6 +65,10 @@ var reEntityHere = new RegExp('^' + ENTITY, 'i'); var reEntityOrEscapedChar = new RegExp('\\\\' + ESCAPABLE + '|' + ENTITY, 'gi'); +var reTicks = new RegExp('`+'); + +var reTicksHere = new RegExp('^`+'); + // Matches a string of non-special characters. var reMain = /^[^\n`\[\]\\!<&*_]+/m; @@ -144,7 +148,7 @@ var spnl = function() { // literal sequence of backticks. var parseBackticks = function(block) { "use strict"; - var ticks = this.match(/^`+/); + var ticks = this.match(reTicksHere); if (!ticks) { return 0; } @@ -152,7 +156,7 @@ var parseBackticks = function(block) { var foundCode = false; var matched; var node; - while (!foundCode && (matched = this.match(/`+/m))) { + while (!foundCode && (matched = this.match(reTicks))) { if (matched === ticks) { node = new Node('Code'); node.literal = this.subject.slice(afterOpenTicks, @@ -757,11 +761,11 @@ var parseReference = function(s, refmap) { // On failure, return false. var parseInline = function(block) { "use strict"; + var res; var c = this.peek(); if (c === -1) { return false; } - var res; switch(c) { case C_NEWLINE: res = this.parseNewline(block); |