Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function escape_plugin(md, tagsToIgnore) {
const HTML_OPEN_CLOSE_TAG_RE = require('markdown-it/lib/common/html_re').HTML_OPEN_CLOSE_TAG_RE;

const specialTagsRegex = Array.from(tagsToIgnore)
.concat(['script|pre|style'])
.concat(['script|pre|style|variable'])
.join('|');
const startingSpecialTagRegex = new RegExp(`^<(${specialTagsRegex})(?=(\\s|>|$))`, 'i');
const endingSpecialTagRegex = new RegExp(`<\\/(${specialTagsRegex})>`, 'i');
Expand Down
13 changes: 8 additions & 5 deletions src/lib/markbind/src/patches/htmlparser2.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ var i = 0,
NO_MATCH = -2,
HAS_MATCHED = -3;

const DEFAULT_SPECIAL_TAGS = [
'script',
'style',
'variable',
];

function whitespace(c) {
return c === " " || c === "\n" || c === "\t" || c === "\f" || c === "\r";
}
Expand Down Expand Up @@ -149,10 +155,7 @@ Tokenizer.prototype._stateText = function(c) {
};


Tokenizer.prototype.specialTagNames = [
'script',
'style',
];
Tokenizer.prototype.specialTagNames = [...DEFAULT_SPECIAL_TAGS];

/**
* Checks whether the token matches one of the first characters of the special tags,
Expand Down Expand Up @@ -485,7 +488,7 @@ Tokenizer.prototype._parse = function(){
* Injects the tagsToIgnore into the Tokenizer's specialTagNames.
*/
function injectIgnoreTags(tagsToIgnore) {
Tokenizer.prototype.specialTagNames = ['script', 'style', ...tagsToIgnore];
Tokenizer.prototype.specialTagNames = [...DEFAULT_SPECIAL_TAGS, ...tagsToIgnore];
}

module.exports = injectIgnoreTags;