|
@ -19,7 +19,7 @@ function replaceAt(str, index, ch) { |
|
|
function process_inlines(tokens, state) { |
|
|
function process_inlines(tokens, state) { |
|
|
var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, |
|
|
var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar, |
|
|
isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, |
|
|
isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace, |
|
|
canOpen, canClose, j, isSingle, stack; |
|
|
canOpen, canClose, j, isSingle, stack, openQuote, closeQuote; |
|
|
|
|
|
|
|
|
stack = []; |
|
|
stack = []; |
|
|
|
|
|
|
|
@ -104,16 +104,28 @@ function process_inlines(tokens, state) { |
|
|
if (stack[j].level < thisLevel) { break; } |
|
|
if (stack[j].level < thisLevel) { break; } |
|
|
if (item.single === isSingle && stack[j].level === thisLevel) { |
|
|
if (item.single === isSingle && stack[j].level === thisLevel) { |
|
|
item = stack[j]; |
|
|
item = stack[j]; |
|
|
|
|
|
|
|
|
if (isSingle) { |
|
|
if (isSingle) { |
|
|
tokens[item.token].content = replaceAt( |
|
|
openQuote = state.md.options.quotes[2]; |
|
|
tokens[item.token].content, item.pos, state.md.options.quotes[2]); |
|
|
closeQuote = state.md.options.quotes[3]; |
|
|
token.content = replaceAt( |
|
|
|
|
|
token.content, t.index, state.md.options.quotes[3]); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
tokens[item.token].content = replaceAt( |
|
|
openQuote = state.md.options.quotes[0]; |
|
|
tokens[item.token].content, item.pos, state.md.options.quotes[0]); |
|
|
closeQuote = state.md.options.quotes[1]; |
|
|
token.content = replaceAt(token.content, t.index, 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; |
|
|
stack.length = j; |
|
|
continue OUTER; |
|
|
continue OUTER; |
|
|
} |
|
|
} |
|
|