Browse Source

Update emphasis rule to the latest CommonMark spec

pull/14/head
Alex Kocharin 10 years ago
parent
commit
5a73b286b6
  1. 19
      lib/rules_inline/emphasis.js

19
lib/rules_inline/emphasis.js

@ -21,8 +21,6 @@ function parseStart(state, start) {
lastChar = state.pending.length !== 0 ? state.pending.charCodeAt(state.pending.length - 1) : -1;
if (lastChar === marker) { return -1; }
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; }
if (pos >= max) { return -1; }
count = pos - start;
@ -103,7 +101,6 @@ module.exports = function emphasis(state/*, silent*/) {
oldCount,
newCount,
stack,
breakOutOfOuterLoop,
max = state.posMax,
start = state.pos,
haveLiteralAsterisk,
@ -142,20 +139,8 @@ module.exports = function emphasis(state/*, silent*/) {
newCount = count;
while (oldCount !== newCount) {
if (oldCount === 3) {
// e.g. `***foo*`
stack.push(3 - newCount);
break;
}
if (newCount < oldCount) {
// assert(oldCount == 2 && newCount == 1)
// i.e. `**foo* bar*`
// not valid for now, but might be in the future
// eslint is misconfigured, so it doesn't accept "break MAIN;"
// here is a crappy workaround
breakOutOfOuterLoop = true;
stack.push(oldCount - newCount);
break;
}
@ -167,8 +152,6 @@ module.exports = function emphasis(state/*, silent*/) {
oldCount = stack.pop();
}
if (breakOutOfOuterLoop) { break; }
if (stack.length === 0) {
startCount = oldCount;
found = true;

Loading…
Cancel
Save