Browse Source

Updated inline text scan logic

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
54990dd7c5
  1. 2
      lib/parser_inline.js
  2. 11
      lib/rules_inline/text.js

2
lib/parser_inline.js

@ -50,7 +50,7 @@ function ParserInline() {
// Rule to skip pure text
// - '{}$%@+=:' reserved for extentions
this.textMatch = /^[^\n\\`*_\[\]!&<{}$%@~+=:]+/;
this.textMatch = /[\n\\`*_\[\]!&<{}$%@~+=:]/;
// By default CommonMark allows too much in links
// If you need to restrict it - override this with your validator.

11
lib/rules_inline/text.js

@ -2,12 +2,15 @@
// and increment current pos
module.exports = function text(state, silent) {
var match = state.src.slice(state.pos).match(state.parser.textMatch);
var str = state.src.slice(state.pos),
next = str.search(state.parser.textMatch);
if (!match) { return false; }
if (next === 0) { return false; }
if (!silent) { state.pending += match[0]; }
state.pos += match[0].length;
if (next < 0) { next = str.length; }
if (!silent) { state.pending += str.slice(0, next); }
state.pos += next;
return true;
};

Loading…
Cancel
Save