|
|
@ -19,7 +19,7 @@ function replaceAt(str, index, ch) { |
|
|
|
function process_inlines(tokens, state) { |
|
|
|
var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, |
|
|
|
isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, |
|
|
|
canOpen, canClose, j, isSingle, stack; |
|
|
|
canOpen, canClose, j, isSingle, stack, openQuote, closeQuote; |
|
|
|
|
|
|
|
stack = []; |
|
|
|
|
|
|
@ -104,16 +104,28 @@ function process_inlines(tokens, state) { |
|
|
|
if (stack[j].level < thisLevel) { break; } |
|
|
|
if (item.single === isSingle && stack[j].level === thisLevel) { |
|
|
|
item = stack[j]; |
|
|
|
|
|
|
|
if (isSingle) { |
|
|
|
tokens[item.token].content = replaceAt( |
|
|
|
tokens[item.token].content, item.pos, state.md.options.quotes[2]); |
|
|
|
token.content = replaceAt( |
|
|
|
token.content, t.index, state.md.options.quotes[3]); |
|
|
|
openQuote = state.md.options.quotes[2]; |
|
|
|
closeQuote = state.md.options.quotes[3]; |
|
|
|
} else { |
|
|
|
tokens[item.token].content = replaceAt( |
|
|
|
tokens[item.token].content, item.pos, state.md.options.quotes[0]); |
|
|
|
token.content = replaceAt(token.content, t.index, state.md.options.quotes[1]); |
|
|
|
openQuote = state.md.options.quotes[0]; |
|
|
|
closeQuote = state.md.options.quotes[1]; |
|
|
|
} |
|
|
|
|
|
|
|
// replace token.content *before* tokens[item.token].content,
|
|
|
|
// because, if they are pointing at the same token, replaceAt
|
|
|
|
// could mess up indices when quote length != 1
|
|
|
|
token.content = replaceAt(token.content, t.index, closeQuote); |
|
|
|
tokens[item.token].content = replaceAt( |
|
|
|
tokens[item.token].content, item.pos, openQuote); |
|
|
|
|
|
|
|
pos += closeQuote.length - 1; |
|
|
|
if (item.token === i) { pos += openQuote.length - 1; } |
|
|
|
|
|
|
|
text = token.content; |
|
|
|
max = text.length; |
|
|
|
|
|
|
|
stack.length = j; |
|
|
|
continue OUTER; |
|
|
|
} |
|
|
|