summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/stmd.js30
1 files changed, 11 insertions, 19 deletions
diff --git a/js/stmd.js b/js/stmd.js
index c5268d8..ea72b9e 100755
--- a/js/stmd.js
+++ b/js/stmd.js
@@ -289,6 +289,7 @@
}
this.pos += numdelims;
+ var delimpos = this.pos;
var next_inline;
var first = [];
@@ -472,36 +473,31 @@
}
}
+ this.pos = startpos;
+ return null;
switch (state) {
case 1: // ***a
- return [{t: 'Str', c: c+c+c}].concat(first);
+ return [{t: 'Emph', c: [{t: 'Str', c: c}]}].concat(first);
case 2: // **a
return [{t: 'Str', c: c+c}].concat(first);
case 3: // *a
return [{t: 'Str', c: c}].concat(first);
case 4: // ***a**b
case 6: // ***a** b
- return [{t: 'Str', c: c+c+c}]
- .concat(first,
- [{t: 'Str', c: c+c}],
- second);
+ return [{t: 'Strong', c:
+ [{t: 'Str', c: c}].concat(first)}].concat(second);
case 5: // ***a*b
case 7: // ***a* b
- return [{t: 'Str', c: c+c+c}]
- .concat(first,
- [{t: 'Str', c: c}],
- second);
+ return [{t: 'Emph', c:
+ [{t: 'Str', c: c+c}].concat(first)}].concat(second);
case 8: // **a *b
return [{t: 'Str', c: c+c}]
.concat(first,
[{t: 'Str', c: c}],
second);
case 9: // *a **b
- return [{t: 'Str', c: c}]
- .concat(first,
- [{t: 'Str', c: c+c}],
- second);
+ return [{t: 'Emph', c: first.concat([{t: 'Str', c: c}])}].concat(second);
default:
console.log("Unknown state, parseEmphasis");
// shouldn't happen
@@ -783,13 +779,11 @@
// and returning the inline parsed.
var parseInline = function() {
var startpos = this.pos;
- /*
var memoized = this.memo[startpos];
if (memoized) {
this.pos = memoized.endpos;
return memoized.inline;
}
- */
var c = this.peek();
if (!c) {
return null;
@@ -830,12 +824,10 @@
this.pos += 1;
res = [{t: 'Str', c: c}];
}
- /*
if (res) {
this.memo[startpos] = { inline: res,
endpos: this.pos };
}
- */
return res;
};
@@ -844,7 +836,7 @@
this.subject = s;
this.pos = 0;
this.refmap = refmap || {};
- // this.memo = {};
+ this.memo = {};
this.last_emphasis_closer = null;
var inlines = [];
var next_inline;
@@ -862,7 +854,7 @@
last_emphasis_closer: null, // used by parseEmphasis method
pos: 0,
refmap: {},
- // memo: {},
+ memo: {},
match: match,
peek: peek,
spnl: spnl,