Browse Source

Check validation flag instead of hardcoding rules

pull/14/head
Alex Kocharin 10 years ago
parent
commit
d5e8e61b6b
  1. 5
      lib/parser_inline.js
  2. 1
      lib/rules_inline/del.js
  3. 1
      lib/rules_inline/emphasis.js
  4. 1
      lib/rules_inline/ins.js
  5. 1
      lib/rules_inline/mark.js
  6. 1
      lib/rules_inline/sub.js
  7. 1
      lib/rules_inline/sup.js

5
lib/parser_inline.js

@ -83,11 +83,6 @@ ParserInline.prototype.skipToken = function (state) {
}
for (i = 0; i < len; i++) {
// TODO: change it to rule chains somehow
if ([ 'autolink', 'backticks', 'escape', 'htmltag', 'links', 'text' ].indexOf(this._rules[i].name) === -1) {
continue;
}
if (this._rules[i](state, true)) {
state.cacheSet(pos, state.pos);
return;

1
lib/rules_inline/del.js

@ -12,6 +12,7 @@ module.exports = function del(state, silent) {
nextChar;
if (state.src.charCodeAt(start) !== 0x7E/* ~ */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 4 >= max) { return false; }
if (state.src.charCodeAt(start + 1) !== 0x7E/* ~ */) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

1
lib/rules_inline/emphasis.js

@ -61,6 +61,7 @@ module.exports = function emphasis(state, silent) {
marker = state.src.charCodeAt(start);
if (marker !== 0x5F/* _ */ && marker !== 0x2A /* * */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
res = scanDelims(state, start);
startCount = res.delims;

1
lib/rules_inline/ins.js

@ -12,6 +12,7 @@ module.exports = function ins(state, silent) {
nextChar;
if (state.src.charCodeAt(start) !== 0x2B/* + */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 4 >= max) { return false; }
if (state.src.charCodeAt(start + 1) !== 0x2B/* + */) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

1
lib/rules_inline/mark.js

@ -12,6 +12,7 @@ module.exports = function del(state, silent) {
nextChar;
if (state.src.charCodeAt(start) !== 0x3D/* = */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 4 >= max) { return false; }
if (state.src.charCodeAt(start + 1) !== 0x3D/* = */) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

1
lib/rules_inline/sub.js

@ -11,6 +11,7 @@ module.exports = function sub(state, silent) {
nextChar;
if (state.src.charCodeAt(start) !== 0x7E/* ~ */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 2 >= max) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

1
lib/rules_inline/sup.js

@ -11,6 +11,7 @@ module.exports = function sup(state, silent) {
nextChar;
if (state.src.charCodeAt(start) !== 0x5E/* ^ */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 2 >= max) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

Loading…
Cancel
Save