From 6ab7cc30a4037f13e7243b4ee0391799baf6f597 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Sun, 11 Jan 2015 11:56:20 +0300 Subject: [PATCH] Use the same regexp for comments as reference parser --- lib/common/html_re.js | 4 +--- lib/rules_inline/html_inline.js | 12 ++---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/common/html_re.js b/lib/common/html_re.js index c1a49fb..85f1127 100644 --- a/lib/common/html_re.js +++ b/lib/common/html_re.js @@ -41,9 +41,7 @@ var open_tag = replace(/<[A-Za-z][A-Za-z0-9\-]*attribute*\s*\/?>/) (); var close_tag = /<\/[A-Za-z][A-Za-z0-9\-]*\s*>/; -// That's less strict than http://www.w3.org/TR/html5/syntax.html#comments -// but we do the rest of check in "inline" rule. -var comment = //; +var comment = /|/; var processing = /<[?].*?[?]>/; var declaration = /]*>/; var cdata = //; diff --git a/lib/rules_inline/html_inline.js b/lib/rules_inline/html_inline.js index f649a27..9b2941a 100644 --- a/lib/rules_inline/html_inline.js +++ b/lib/rules_inline/html_inline.js @@ -5,7 +5,6 @@ var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE; -var COMMENT_RE = /^$/; function isLetter(ch) { /*eslint no-bitwise:0*/ @@ -15,7 +14,7 @@ function isLetter(ch) { module.exports = function html_inline(state, silent) { - var ch, match, max, content, pos = state.pos; + var ch, match, max, pos = state.pos; if (!state.md.options.html) { return false; } @@ -38,17 +37,10 @@ module.exports = function html_inline(state, silent) { match = state.src.slice(pos).match(HTML_TAG_RE); if (!match) { return false; } - content = state.src.slice(pos, pos + match[0].length); - - // Additional check for comments - if (COMMENT_RE.test(content)) { - if (/(^>|^->|--|-$)/.test(content.slice(4, -3))) { return false; } - } - if (!silent) { state.push({ type: 'html_inline', - content: content, + content: state.src.slice(pos, pos + match[0].length), level: state.level }); }