Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow variable tags to contain malformed xml #1193

Merged
merged 1 commit into from
Apr 12, 2020
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;