|
|
@ -97,13 +97,11 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
count, |
|
|
|
oldLength, |
|
|
|
oldPending, |
|
|
|
oldFlag, |
|
|
|
found, |
|
|
|
ok, |
|
|
|
i, |
|
|
|
oldCount, |
|
|
|
newCount, |
|
|
|
len, |
|
|
|
rules, |
|
|
|
stack, |
|
|
|
breakOutOfOuterLoop, |
|
|
|
max = state.posMax, |
|
|
@ -113,6 +111,11 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
|
|
|
|
if (marker !== 0x5F/* _ */ && marker !== 0x2A /* * */) { return false; } |
|
|
|
|
|
|
|
// skip emphasis in links because it has lower priority, compare:
|
|
|
|
// [foo *bar]()*
|
|
|
|
// [foo `bar]()`
|
|
|
|
if (state.validateInsideEm || state.validateInsideLink) { return false; } |
|
|
|
|
|
|
|
startCount = parseStart(state, start); |
|
|
|
if (startCount < 0) { return false; } |
|
|
|
if (startCount >= 4) { |
|
|
@ -123,11 +126,11 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
|
|
|
|
oldLength = state.tokens.length; |
|
|
|
oldPending = state.pending; |
|
|
|
oldFlag = state.validateInsideEm; |
|
|
|
|
|
|
|
state.pos = start + startCount; |
|
|
|
stack = [ startCount ]; |
|
|
|
rules = state.lexer.rules; |
|
|
|
len = rules.length; |
|
|
|
state.validateInsideEm = true; |
|
|
|
|
|
|
|
while (state.pos < max) { |
|
|
|
if (state.src.charCodeAt(state.pos) === marker && !haveLiteralAsterisk) { |
|
|
@ -181,10 +184,7 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (i = 0; i < len; i++) { |
|
|
|
if (rules[i] !== emphasis) { ok = rules[i](state); } |
|
|
|
if (ok) { break; } |
|
|
|
} |
|
|
|
ok = state.lexer.tokenizeSingle(state); |
|
|
|
|
|
|
|
if (ok) { |
|
|
|
haveLiteralAsterisk = false; |
|
|
@ -198,6 +198,7 @@ module.exports = function emphasis(state/*, silent*/) { |
|
|
|
// restore old state
|
|
|
|
state.tokens.length = oldLength; |
|
|
|
state.pending = oldPending; |
|
|
|
state.validateInsideEm = oldFlag; |
|
|
|
|
|
|
|
if (!found) { |
|
|
|
// parser failed to find ending tag, so it's not valid emphasis
|
|
|
|