|
@ -4504,9 +4504,9 @@ module.exports = function footnote(state, startLine, endLine, silent) { |
|
|
pos++; |
|
|
pos++; |
|
|
|
|
|
|
|
|
if (!state.env.footnotes) { state.env.footnotes = {}; } |
|
|
if (!state.env.footnotes) { state.env.footnotes = {}; } |
|
|
if (!state.env.footnotes.refs) { state.env.footnotes.refs = Object.create(null); } |
|
|
if (!state.env.footnotes.refs) { state.env.footnotes.refs = {}; } |
|
|
label = state.src.slice(start + 2, pos - 2); |
|
|
label = state.src.slice(start + 2, pos - 2); |
|
|
state.env.footnotes.refs[label] = -1; |
|
|
state.env.footnotes.refs[':' + label] = -1; |
|
|
|
|
|
|
|
|
state.tokens.push({ |
|
|
state.tokens.push({ |
|
|
type: 'footnote_reference_open', |
|
|
type: 'footnote_reference_open', |
|
@ -5444,7 +5444,9 @@ function parseAbbr(str, parserInline, options, env) { |
|
|
title = str.slice(labelEnd + 2, pos).trim(); |
|
|
title = str.slice(labelEnd + 2, pos).trim(); |
|
|
if (title.length === 0) { return -1; } |
|
|
if (title.length === 0) { return -1; } |
|
|
if (!env.abbreviations) { env.abbreviations = {}; } |
|
|
if (!env.abbreviations) { env.abbreviations = {}; } |
|
|
env.abbreviations[label] = env.abbreviations[label] || title; |
|
|
if (env.abbreviations[':' + label] === undefined) { |
|
|
|
|
|
env.abbreviations[':' + label] = title; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return pos; |
|
|
return pos; |
|
|
} |
|
|
} |
|
@ -5501,7 +5503,9 @@ module.exports = function abbr2(state) { |
|
|
if (!state.env.abbreviations) { return; } |
|
|
if (!state.env.abbreviations) { return; } |
|
|
if (!state.env.abbrRegExp) { |
|
|
if (!state.env.abbrRegExp) { |
|
|
regText = '(^|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])' |
|
|
regText = '(^|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])' |
|
|
+ '(' + Object.keys(state.env.abbreviations).sort(function (a, b) { |
|
|
+ '(' + Object.keys(state.env.abbreviations).map(function (x) { |
|
|
|
|
|
return x.substr(1); |
|
|
|
|
|
}).sort(function (a, b) { |
|
|
return b.length - a.length; |
|
|
return b.length - a.length; |
|
|
}).map(regEscape).join('|') + ')' |
|
|
}).map(regEscape).join('|') + ')' |
|
|
+ '($|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])'; |
|
|
+ '($|[' + PUNCT_CHARS.split('').map(regEscape).join('') + '])'; |
|
@ -5535,7 +5539,7 @@ module.exports = function abbr2(state) { |
|
|
|
|
|
|
|
|
nodes.push({ |
|
|
nodes.push({ |
|
|
type: 'abbr_open', |
|
|
type: 'abbr_open', |
|
|
title: state.env.abbreviations[m[2]], |
|
|
title: state.env.abbreviations[':' + m[2]], |
|
|
level: level++ |
|
|
level: level++ |
|
|
}); |
|
|
}); |
|
|
nodes.push({ |
|
|
nodes.push({ |
|
@ -5593,7 +5597,7 @@ module.exports = function footnote_block(state) { |
|
|
var i, l, j, t, lastParagraph, list, tokens, current, currentLabel, |
|
|
var i, l, j, t, lastParagraph, list, tokens, current, currentLabel, |
|
|
level = 0, |
|
|
level = 0, |
|
|
insideRef = false, |
|
|
insideRef = false, |
|
|
refTokens = Object.create(null); |
|
|
refTokens = {}; |
|
|
|
|
|
|
|
|
if (!state.env.footnotes) { return; } |
|
|
if (!state.env.footnotes) { return; } |
|
|
|
|
|
|
|
@ -5606,7 +5610,7 @@ module.exports = function footnote_block(state) { |
|
|
} |
|
|
} |
|
|
if (tok.type === 'footnote_reference_close') { |
|
|
if (tok.type === 'footnote_reference_close') { |
|
|
insideRef = false; |
|
|
insideRef = false; |
|
|
refTokens[currentLabel] = current; |
|
|
refTokens[':' + currentLabel] = current; |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
if (insideRef) { current.push(tok); } |
|
|
if (insideRef) { current.push(tok); } |
|
@ -5646,7 +5650,7 @@ module.exports = function footnote_block(state) { |
|
|
level: --level |
|
|
level: --level |
|
|
}); |
|
|
}); |
|
|
} else if (list[i].label) { |
|
|
} else if (list[i].label) { |
|
|
tokens = refTokens[list[i].label]; |
|
|
tokens = refTokens[':' + list[i].label]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
state.tokens = state.tokens.concat(tokens); |
|
|
state.tokens = state.tokens.concat(tokens); |
|
@ -5920,7 +5924,9 @@ function parseReference(str, parser, options, env) { |
|
|
if (pos < max && state.src.charCodeAt(pos) !== 0x0A) { return -1; } |
|
|
if (pos < max && state.src.charCodeAt(pos) !== 0x0A) { return -1; } |
|
|
|
|
|
|
|
|
label = normalizeReference(str.slice(1, labelEnd)); |
|
|
label = normalizeReference(str.slice(1, labelEnd)); |
|
|
env.references[label] = env.references[label] || { title: title, href: href }; |
|
|
if (env.references[':' + label] === undefined) { |
|
|
|
|
|
env.references[':' + label] = { title: title, href: href }; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return pos; |
|
|
return pos; |
|
|
} |
|
|
} |
|
@ -6693,17 +6699,17 @@ module.exports = function footnote_ref(state, silent) { |
|
|
pos++; |
|
|
pos++; |
|
|
|
|
|
|
|
|
label = state.src.slice(start + 2, pos - 1); |
|
|
label = state.src.slice(start + 2, pos - 1); |
|
|
if (state.env.footnotes.refs[label] === undefined) { return false; } |
|
|
if (state.env.footnotes.refs[':' + label] === undefined) { return false; } |
|
|
|
|
|
|
|
|
if (!silent) { |
|
|
if (!silent) { |
|
|
if (!state.env.footnotes.list) { state.env.footnotes.list = []; } |
|
|
if (!state.env.footnotes.list) { state.env.footnotes.list = []; } |
|
|
|
|
|
|
|
|
if (state.env.footnotes.refs[label] < 0) { |
|
|
if (state.env.footnotes.refs[':' + label] < 0) { |
|
|
footnoteId = state.env.footnotes.list.length; |
|
|
footnoteId = state.env.footnotes.list.length; |
|
|
state.env.footnotes.list[footnoteId] = { label: label, count: 0 }; |
|
|
state.env.footnotes.list[footnoteId] = { label: label, count: 0 }; |
|
|
state.env.footnotes.refs[label] = footnoteId; |
|
|
state.env.footnotes.refs[':' + label] = footnoteId; |
|
|
} else { |
|
|
} else { |
|
|
footnoteId = state.env.footnotes.refs[label]; |
|
|
footnoteId = state.env.footnotes.refs[':' + label]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
footnoteSubId = state.env.footnotes.list[footnoteId].count; |
|
|
footnoteSubId = state.env.footnotes.list[footnoteId].count; |
|
@ -6982,7 +6988,7 @@ module.exports = function links(state, silent) { |
|
|
// (collapsed reference link and shortcut reference link respectively)
|
|
|
// (collapsed reference link and shortcut reference link respectively)
|
|
|
if (!label) { label = state.src.slice(labelStart, labelEnd); } |
|
|
if (!label) { label = state.src.slice(labelStart, labelEnd); } |
|
|
|
|
|
|
|
|
ref = state.env.references[normalizeReference(label)]; |
|
|
ref = state.env.references[':' + normalizeReference(label)]; |
|
|
if (!ref) { |
|
|
if (!ref) { |
|
|
state.pos = oldPos; |
|
|
state.pos = oldPos; |
|
|
return false; |
|
|
return false; |
|
|