|
|
@ -15,11 +15,11 @@ function isAlphaNum(code) { |
|
|
|
// note: in case if 4+ markers it is still not a valid emphasis,
|
|
|
|
// should be treated as a special case
|
|
|
|
function parseStart(state, start) { |
|
|
|
var pos = start, lastChar, count, |
|
|
|
var pos = start, lastChar, nextChar, count, |
|
|
|
max = state.posMax, |
|
|
|
marker = state.src.charCodeAt(start); |
|
|
|
|
|
|
|
lastChar = state.pending.length !== 0 ? state.pending.charCodeAt(state.pending.length - 1) : -1; |
|
|
|
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1; |
|
|
|
|
|
|
|
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } |
|
|
|
if (pos >= max) { return -1; } |
|
|
@ -40,7 +40,8 @@ function parseStart(state, start) { |
|
|
|
} |
|
|
|
|
|
|
|
// check condition 2, marker followed by whitespace
|
|
|
|
if (state.src.charCodeAt(pos) === 0x20) { return -1; } |
|
|
|
nextChar = state.src.charCodeAt(pos); |
|
|
|
if (nextChar === 0x20 || nextChar === 0x0A) { return -1; } |
|
|
|
|
|
|
|
if (marker === 0x5F /* _ */) { |
|
|
|
// check condition 3, if it's the beginning of the word
|
|
|
@ -61,7 +62,7 @@ function parseEnd(state, start) { |
|
|
|
max = state.posMax, |
|
|
|
marker = state.src.charCodeAt(start); |
|
|
|
|
|
|
|
lastChar = state.pending.length !== 0 ? state.pending.charCodeAt(state.pending.length - 1) : -1; |
|
|
|
lastChar = start > 0 ? state.src.charCodeAt(start - 1) : -1; |
|
|
|
|
|
|
|
while (pos < max && state.src.charCodeAt(pos) === marker) { pos++; } |
|
|
|
count = pos - start; |
|
|
@ -80,7 +81,7 @@ function parseEnd(state, start) { |
|
|
|
} |
|
|
|
|
|
|
|
// check condition 2, marker preceded by whitespace
|
|
|
|
if (lastChar === 0x20) { return -1; } |
|
|
|
if (lastChar === 0x20 || lastChar === 0x0A) { return -1; } |
|
|
|
|
|
|
|
if (marker === 0x5F) { |
|
|
|
// check condition 3, if it's the end of the word
|
|
|
|