|
@ -8,12 +8,6 @@ var isPunctChar = require('../common/utils').isPunctChar; |
|
|
var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct; |
|
|
var isMdAsciiPunct = require('../common/utils').isMdAsciiPunct; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isAlphaNum(code) { |
|
|
|
|
|
return (code >= 0x30 /* 0 */ && code <= 0x39 /* 9 */) || |
|
|
|
|
|
(code >= 0x41 /* A */ && code <= 0x5A /* Z */) || |
|
|
|
|
|
(code >= 0x61 /* a */ && code <= 0x7A /* z */); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// parse sequence of emphasis markers,
|
|
|
// parse sequence of emphasis markers,
|
|
|
// "start" should point at a valid marker
|
|
|
// "start" should point at a valid marker
|
|
|
function scanDelims(state, start) { |
|
|
function scanDelims(state, start) { |
|
@ -37,13 +31,15 @@ function scanDelims(state, start) { |
|
|
(isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar))); |
|
|
(isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar))); |
|
|
isNextPunctChar = nextChar >= 0 && |
|
|
isNextPunctChar = nextChar >= 0 && |
|
|
(isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar))); |
|
|
(isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar))); |
|
|
isLastWhiteSpace = lastChar >= 0 && isWhiteSpace(lastChar); |
|
|
|
|
|
isNextWhiteSpace = nextChar >= 0 && isWhiteSpace(nextChar); |
|
|
// begin/end of the line counts as a whitespace too
|
|
|
|
|
|
isLastWhiteSpace = lastChar < 0 || isWhiteSpace(lastChar); |
|
|
|
|
|
isNextWhiteSpace = nextChar < 0 || isWhiteSpace(nextChar); |
|
|
|
|
|
|
|
|
if (isNextWhiteSpace) { |
|
|
if (isNextWhiteSpace) { |
|
|
can_open = false; |
|
|
can_open = false; |
|
|
} else if (isNextPunctChar) { |
|
|
} else if (isNextPunctChar) { |
|
|
if (!(isLastWhiteSpace || isLastPunctChar || lastChar === -1)) { |
|
|
if (!(isLastWhiteSpace || isLastPunctChar)) { |
|
|
can_open = false; |
|
|
can_open = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -51,15 +47,16 @@ function scanDelims(state, start) { |
|
|
if (isLastWhiteSpace) { |
|
|
if (isLastWhiteSpace) { |
|
|
can_close = false; |
|
|
can_close = false; |
|
|
} else if (isLastPunctChar) { |
|
|
} else if (isLastPunctChar) { |
|
|
if (!(isNextWhiteSpace || isNextPunctChar || nextChar === -1)) { |
|
|
if (!(isNextWhiteSpace || isNextPunctChar)) { |
|
|
can_close = false; |
|
|
can_close = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (marker === 0x5F /* _ */) { |
|
|
if (marker === 0x5F /* _ */) { |
|
|
// check if we aren't inside the word
|
|
|
if (can_open && can_close) { |
|
|
if (isAlphaNum(lastChar)) { can_open = false; } |
|
|
// "_" inside a word can neither open nor close an emphasis
|
|
|
if (isAlphaNum(nextChar)) { can_close = false; } |
|
|
can_open = can_close = false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|