Browse Source

Limit element depth

pull/14/head
Alex Kocharin 10 years ago
parent
commit
9aea37acc1
  1. 1
      lib/defaults.js
  2. 2
      lib/rules_block/blockquote.js
  3. 3
      lib/rules_block/list.js
  4. 2
      lib/rules_inline/emphasis.js
  5. 1
      lib/rules_inline/links.js

1
lib/defaults.js

@ -7,6 +7,7 @@ module.exports = {
html: false,
xhtml: false,
breaks: false,
level: 10,
langprefix: 'language-',
highlight: function (/*str*/) { return ''; }
};

2
lib/rules_block/blockquote.js

@ -17,6 +17,8 @@ module.exports = function blockquote(state, startLine, endLine, silent) {
// check the block quote marker
if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }
if (state.level >= state.options.level) { return false; }
// we know that it's going to be a valid blockquote,
// so no point trying to find the end of it in silent mode
if (silent) { return true; }

3
lib/rules_block/list.js

@ -100,6 +100,9 @@ module.exports = function list(state, startLine, endLine, silent) {
} else {
return false;
}
if (state.level >= state.options.level) { return false; }
// We should terminate list on style change. Remember first one to compare.
markerCharCode = state.src.charCodeAt(posAfterMarker - 1);

2
lib/rules_inline/emphasis.js

@ -124,6 +124,8 @@ module.exports = function emphasis(state/*, silent*/) {
return true;
}
if (state.level >= state.options.level) { return false; }
oldLength = state.tokens.length;
oldPending = state.pending;
oldFlag = state.validateInsideEm;

1
lib/rules_inline/links.js

@ -179,6 +179,7 @@ function links(state) {
}
if (marker !== 0x5B/* [ */) { return false; }
if (state.level >= state.options.level) { return false; }
labelStart = start + 1;
labelEnd = parseLinkLabel(state, start);

Loading…
Cancel
Save