@ -19,7 +19,8 @@ function scanDelims(state, start) {
max = state . posMax ,
max = state . posMax ,
marker = state . src . charCodeAt ( start ) ;
marker = state . src . charCodeAt ( start ) ;
lastChar = start > 0 ? state . src . charCodeAt ( start - 1 ) : - 1 ;
// treat beginning of the line as a whitespace
lastChar = start > 0 ? state . src . charCodeAt ( start - 1 ) : 0x20 ;
while ( pos < max && state . src . charCodeAt ( pos ) === marker ) { pos ++ ; }
while ( pos < max && state . src . charCodeAt ( pos ) === marker ) { pos ++ ; }
@ -29,16 +30,14 @@ function scanDelims(state, start) {
count = pos - start ;
count = pos - start ;
nextChar = pos < max ? state . src . charCodeAt ( pos ) : - 1 ;
// treat end of the line as a whitespace
nextChar = pos < max ? state . src . charCodeAt ( pos ) : 0x20 ;
isLastPunctChar = lastChar >= 0 &&
isLastPunctChar = isMdAsciiPunct ( lastChar ) || isPunctChar ( String . fromCharCode ( lastChar ) ) ;
( isMdAsciiPunct ( lastChar ) || isPunctChar ( String . fromCharCode ( lastChar ) ) ) ;
isNextPunctChar = isMdAsciiPunct ( nextChar ) || isPunctChar ( String . fromCharCode ( nextChar ) ) ;
isNextPunctChar = nextChar >= 0 &&
( isMdAsciiPunct ( nextChar ) || isPunctChar ( String . fromCharCode ( nextChar ) ) ) ;
// begin/end of the line counts as a whitespace too
isLastWhiteSpace = isWhiteSpace ( lastChar ) ;
isLastWhiteSpace = lastChar < 0 || isWhiteSpace ( lastChar ) ;
isNextWhiteSpace = isWhiteSpace ( nextChar ) ;
isNextWhiteSpace = nextChar < 0 || isWhiteSpace ( nextChar ) ;
if ( isNextWhiteSpace ) {
if ( isNextWhiteSpace ) {
can_open = false ;
can_open = false ;
@ -59,7 +58,8 @@ function scanDelims(state, start) {
if ( marker === 0x5F /* _ */ ) {
if ( marker === 0x5F /* _ */ ) {
if ( can_open && can_close ) {
if ( can_open && can_close ) {
// "_" inside a word can neither open nor close an emphasis
// "_" inside a word can neither open nor close an emphasis
can_open = can_close = false ;
can_open = false ;
can_close = isNextPunctChar ;
}
}
}
}