summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-09-26 10:45:51 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-09-26 10:45:51 -0700
commitde2a35a4dcb3b051df328ec2c204f08c77a5ad3d (patch)
treeabbb1016a8fbe11f5bf7041e096ef5a69e502127 /js
parent7f4b2f7f3949f807d5dafe2219280a0f1419b0e2 (diff)
Simple fallback if we don't match emphasis.
The other approach led to wrong results on: *hi _there*
Diffstat (limited to 'js')
-rwxr-xr-xjs/stmd.js31
1 files changed, 6 insertions, 25 deletions
diff --git a/js/stmd.js b/js/stmd.js
index 552fe16..589ac03 100755
--- a/js/stmd.js
+++ b/js/stmd.js
@@ -302,6 +302,9 @@
this.pos += numdelims;
+ var fallbackpos = this.pos;
+ var fallback = Str(this.subject.slice(startpos, fallbackpos));
+
var next_inline;
var first = [];
var second = [];
@@ -453,31 +456,9 @@
}
- switch (state) {
- case 1: // ***a
- return [Str(c+c+c)].concat(first);
- case 2: // **a
- return [Str(c+c)].concat(first);
- case 3: // *a
- return [Str(c)].concat(first);
- case 4: // ***a**b
- case 6: // ***a** b
- return [Str(c+c+c)]
- .concat(first, [Str(c+c)], second);
- case 5: // ***a*b
- case 7: // ***a* b
- return [Str(c+c+c)]
- .concat(first, [Str(c)], second);
- case 8: // **a *b
- return [Str(c+c)]
- .concat(first, [Str(c)], second);
- case 9: // *a **b
- return [Str(c)]
- .concat(first, [Str(c+c)], second);
- default:
- console.log("Unknown state, parseEmphasis");
- // shouldn't happen
- }
+ // we didn't match emphasis: fallback
+ this.pos = fallbackpos;
+ return [fallback];
};