|
|
@ -91,11 +91,9 @@ function parseEnd(state, start) { |
|
|
|
return count; |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = function emphasis(state/*, silent*/) { |
|
|
|
module.exports = function emphasis(state, silent) { |
|
|
|
var startCount, |
|
|
|
count, |
|
|
|
oldLength, |
|
|
|
oldPending, |
|
|
|
oldFlag, |
|
|
|
found, |
|
|
|
ok, |
|
|
@ -124,8 +122,6 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
|
|
|
|
if (state.level >= state.options.maxNesting) { return false; } |
|
|
|
|
|
|
|
oldLength = state.tokens.length; |
|
|
|
oldPending = state.pending; |
|
|
|
oldFlag = state.validateInsideEm; |
|
|
|
|
|
|
|
state.pos = start + startCount; |
|
|
@ -170,20 +166,17 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ok = state.parser.tokenizeSingle(state); |
|
|
|
ok = state.parser.skipToken(state); |
|
|
|
|
|
|
|
if (ok) { |
|
|
|
haveLiteralAsterisk = false; |
|
|
|
} else { |
|
|
|
haveLiteralAsterisk = state.src.charCodeAt(state.pos) === marker; |
|
|
|
state.pending += state.src[state.pos]; |
|
|
|
state.pos++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// restore old state
|
|
|
|
state.tokens.length = oldLength; |
|
|
|
state.pending = oldPending; |
|
|
|
state.validateInsideEm = oldFlag; |
|
|
|
|
|
|
|
if (!found) { |
|
|
@ -193,23 +186,25 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
} |
|
|
|
|
|
|
|
// found!
|
|
|
|
state.posMax = state.pos; |
|
|
|
state.pos = start + startCount; |
|
|
|
if (!silent) { |
|
|
|
state.posMax = state.pos; |
|
|
|
state.pos = start + startCount; |
|
|
|
|
|
|
|
if (startCount === 2 || startCount === 3) { |
|
|
|
state.push({ type: 'strong_open', level: state.level++ }); |
|
|
|
} |
|
|
|
if (startCount === 1 || startCount === 3) { |
|
|
|
state.push({ type: 'em_open', level: state.level++ }); |
|
|
|
} |
|
|
|
if (startCount === 2 || startCount === 3) { |
|
|
|
state.push({ type: 'strong_open', level: state.level++ }); |
|
|
|
} |
|
|
|
if (startCount === 1 || startCount === 3) { |
|
|
|
state.push({ type: 'em_open', level: state.level++ }); |
|
|
|
} |
|
|
|
|
|
|
|
state.parser.tokenize(state); |
|
|
|
state.parser.tokenize(state); |
|
|
|
|
|
|
|
if (startCount === 1 || startCount === 3) { |
|
|
|
state.push({ type: 'em_close', level: --state.level }); |
|
|
|
} |
|
|
|
if (startCount === 2 || startCount === 3) { |
|
|
|
state.push({ type: 'strong_close', level: --state.level }); |
|
|
|
if (startCount === 1 || startCount === 3) { |
|
|
|
state.push({ type: 'em_close', level: --state.level }); |
|
|
|
} |
|
|
|
if (startCount === 2 || startCount === 3) { |
|
|
|
state.push({ type: 'strong_close', level: --state.level }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
state.pos = state.posMax + startCount; |
|
|
|