Browse Source

Moved tight paragraphs marking to separate fn

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
2ef8825a7f
  1. 26
      lib/rules_block/list.js

26
lib/rules_block/list.js

@ -68,6 +68,19 @@ function skipOrderedListMarker(state, startLine) {
return pos;
}
function markTightParagraphs(state, idx) {
var i, l,
level = state.level + 2;
for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
state.tokens[i + 2].tight = true;
state.tokens[i].tight = true;
i += 2;
}
}
}
module.exports = function list(state, startLine, endLine, silent) {
var nextLine,
@ -90,7 +103,7 @@ module.exports = function list(state, startLine, endLine, silent) {
itemLines,
tight = true,
terminatorRules = state.parser._rulesListTerm,
i, l, terminate, level, tokens;
i, l, terminate;
// Detect list type and position after marker
if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
@ -247,16 +260,7 @@ module.exports = function list(state, startLine, endLine, silent) {
// mark paragraphs tight if needed
if (tight) {
level = state.level + 2;
tokens = state.tokens;
for (i = listTokIdx + 2, l = tokens.length - 2; i < l; i++) {
if (tokens[i].level === level && tokens[i].type === 'paragraph_open') {
tokens[i].tight = true;
i += 2;
tokens[i].tight = true;
}
}
markTightParagraphs(state, listTokIdx);
}
return true;

Loading…
Cancel
Save