Skip to content

Commit 89a7f79

Browse files
authored
fix: posMax could be empty when push pending string (#8)
1 parent 8ca4bd3 commit 89a7f79

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/rules_inline/state_inline.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ function StateInline(src, md, env, outTokens) {
2121
this.pos = 0;
2222
this.posMax = this.src.length;
2323
this.level = 0;
24-
this.pending = '';
24+
this._pending = '';
25+
Object.defineProperty(this, 'pending', {
26+
get: function () { return this._pending; },
27+
set: function (val) {
28+
if (this._pending.length === 0) {
29+
this.posStart.push(this.pos);
30+
}
31+
this._pending = val;
32+
}
33+
});
2534
this.pendingLevel = 0;
2635

2736
// Stores { start: end } pairs. Useful for backtrack

lib/rules_inline/text.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ module.exports = function text(state, silent) {
5252

5353
if (pos === state.pos) { return false; }
5454

55-
if (!silent) {
56-
state.pending += state.src.slice(state.pos, pos);
57-
state.posStart.push(state.pos);
58-
}
55+
if (!silent) { state.pending += state.src.slice(state.pos, pos); }
5956

6057
state.pos = pos;
6158

0 commit comments

Comments
 (0)