From 589d607197bb21648ca8bb564b822560676e8edf Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 9 Jan 2015 23:08:34 -0800 Subject: Put backtick regexes in variables. --- js/lib/inlines.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'js/lib') 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); -- cgit v1.2.3