From c2aa7bf38fb30de2d04f87f8e7780e4c768ae6b1 Mon Sep 17 00:00:00 2001 From: Minteck Date: Thu, 20 Jan 2022 13:43:34 +0100 Subject: Initial commit --- .../markdown-it/lib/rules_inline/html_inline.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 node_modules/markdown-it/lib/rules_inline/html_inline.js (limited to 'node_modules/markdown-it/lib/rules_inline/html_inline.js') diff --git a/node_modules/markdown-it/lib/rules_inline/html_inline.js b/node_modules/markdown-it/lib/rules_inline/html_inline.js new file mode 100644 index 0000000..28c7980 --- /dev/null +++ b/node_modules/markdown-it/lib/rules_inline/html_inline.js @@ -0,0 +1,47 @@ +// Process html tags + +'use strict'; + + +var HTML_TAG_RE = require('../common/html_re').HTML_TAG_RE; + + +function isLetter(ch) { + /*eslint no-bitwise:0*/ + var lc = ch | 0x20; // to lower case + return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */); +} + + +module.exports = function html_inline(state, silent) { + var ch, match, max, token, + pos = state.pos; + + if (!state.md.options.html) { return false; } + + // Check start + max = state.posMax; + if (state.src.charCodeAt(pos) !== 0x3C/* < */ || + pos + 2 >= max) { + return false; + } + + // Quick fail on second char + ch = state.src.charCodeAt(pos + 1); + if (ch !== 0x21/* ! */ && + ch !== 0x3F/* ? */ && + ch !== 0x2F/* / */ && + !isLetter(ch)) { + return false; + } + + match = state.src.slice(pos).match(HTML_TAG_RE); + if (!match) { return false; } + + if (!silent) { + token = state.push('html_inline', '', 0); + token.content = state.src.slice(pos, pos + match[0].length); + } + state.pos += match[0].length; + return true; +}; -- cgit