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