cmark

My personal build of CMark ✏️

Commit
589d607197bb21648ca8bb564b822560676e8edf
Parent
1640365a8ba0c414e03922796dd5a0ed0e600bda
Author
John MacFarlane <jgm@berkeley.edu>
Date

Put backtick regexes in variables.

Diffstat

1 file changed, 7 insertions, 3 deletions

Status File Name N° Changes Insertions Deletions
Modified js/lib/inlines.js 10 7 3
diff --git 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);