Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
https://markdown-it.github.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
782 B
37 lines
782 B
9 years ago
|
// For each opening emphasis-like marker find a matching closing one
|
||
|
//
|
||
|
'use strict';
|
||
|
|
||
|
|
||
|
module.exports = function link_pairs(state) {
|
||
|
var i, j, lastDelim, currDelim,
|
||
|
delimiters = state.delimiters,
|
||
|
max = state.delimiters.length;
|
||
|
|
||
|
for (i = 0; i < max; i++) {
|
||
|
lastDelim = delimiters[i];
|
||
|
|
||
|
if (!lastDelim.close) { continue; }
|
||
|
|
||
|
j = i - lastDelim.jump - 1;
|
||
|
|
||
|
while (j >= 0) {
|
||
|
currDelim = delimiters[j];
|
||
|
|
||
|
if (currDelim.open &&
|
||
|
currDelim.marker === lastDelim.marker &&
|
||
|
currDelim.end < 0 &&
|
||
|
currDelim.level === lastDelim.level) {
|
||
|
|
||
|
lastDelim.jump = i - j;
|
||
|
lastDelim.open = false;
|
||
|
currDelim.end = i;
|
||
|
currDelim.jump = 0;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
j -= currDelim.jump + 1;
|
||
|
}
|
||
|
}
|
||
|
};
|