From 5f56a1988ff8edfc020c97e37dbf834b499157d6 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Wed, 10 Sep 2014 09:30:23 -0700
Subject: Fixed bug.

---
 js/stmd.js | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/js/stmd.js b/js/stmd.js
index 7c7362e..0cfb6b3 100755
--- a/js/stmd.js
+++ b/js/stmd.js
@@ -70,8 +70,9 @@ var reAllTab = /\t/g;
 var reHrule = /^(?:(?:\* *){3,}|(?:_ *){3,}|(?:- *){3,}) *$/;
 
 // Matches a character with a special meaning in markdown,
-// or a string of non-special characters.
-var reMain = /^(?:[\n`\[\]\\!<&*_]|(?: *[^\n `\[\]\\!<&*_]+)+|[ \n]+)/m;
+// or a string of non-special characters.  Note:  we match
+// clumps of _ or * or `, because they need to be handled in groups.
+var reMain = /^(?:[_*`\n]+|[\[\]\\!<&*_]|(?: *[^\n `\[\]\\!<&*_]+)+|[ \n]+)/m;
 
 // UTILITY FUNCTIONS
 
@@ -277,16 +278,16 @@ var parseEmphasis = function() {
   res = this.scanDelims(c);
   numdelims = res.numdelims;
 
-  if (numdelims >= 4) {
-      this.pos += numdelims;
-      return {t: 'Str', c: this.subject.slice(startpos, startpos + numdelims)};
-  }
-
-  if (!res.can_open || numdelims === 0) {
+  if (numdelims === 0) {
     this.pos = startpos;
     return null;
   }
 
+  if (numdelims >= 4 || !res.can_open) {
+      this.pos += numdelims;
+      return {t: 'Str', c: this.subject.slice(startpos, startpos + numdelims)};
+  }
+
   this.pos += numdelims;
 
   var next_inline;
-- 
cgit v1.2.3