Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if ('pre' == tag.name) this.escape = true;
if (!this.hasCompiledTag) {
if (!this.hasCompiledDoctype && 'html' == name) {
this.visitDoctype();
}
this.hasCompiledTag = true;
}
// pretty print
if (pp && !tag.isInline())
this.prettyIndent(0, true);
if (tag.selfClosing || (!this.xml && selfClosing.indexOf(tag.name) !== -1)) {
this.buffer('<');
bufferName();
this.visitAttributes(tag.attrs, tag.attributeBlocks);
this.terse
? this.buffer('>')
: this.buffer('/>');
// if it is non-empty throw an error
if (tag.block &&
!(tag.block.type === 'Block' && tag.block.nodes.length === 0) &&
tag.block.nodes.some(function (tag) {
return tag.type !== 'Text' || !/^\s*$/.test(tag.val)
})) {
throw errorAtNode(tag, new Error(name + ' is self closing and should not have content.'));
}
} else {
// Optimize attributes buffering
}
if ('pre' == tag.name) this.escape = true;
if (!this.hasCompiledTag) {
if (!this.hasCompiledDoctype && 'html' == name) {
this.visitDoctype();
}
this.hasCompiledTag = true;
}
// pretty print
if (pp && !tag.isInline())
this.prettyIndent(0, true);
if (tag.selfClosing || (!this.xml && selfClosing.indexOf(tag.name) !== -1)) {
this.buffer('<');
bufferName();
this.visitAttributes(tag.attrs, tag.attributeBlocks);
this.terse
? this.buffer('>')
: this.buffer('/>');
// if it is non-empty throw an error
if (tag.block &&
!(tag.block.type === 'Block' && tag.block.nodes.length === 0) &&
tag.block.nodes.some(function (tag) {
return tag.type !== 'Text' || !/^\s*$/.test(tag.val)
})) {
throw errorAtNode(tag, new Error(name + ' is self closing and should not have content.'));
}
} else {
// Optimize attributes buffering
}
if ('pre' == tag.name) this.escape = true;
if (!this.hasCompiledTag) {
if (!this.hasCompiledDoctype && 'html' == name) {
this.visitDoctype();
}
this.hasCompiledTag = true;
}
// pretty print
if (pp && !tag.isInline())
this.prettyIndent(0, true);
if (tag.selfClosing || (!this.xml && selfClosing.indexOf(tag.name) !== -1)) {
this.buffer('<');
bufferName();
this.visitAttributes(tag.attrs, tag.attributeBlocks);
this.terse
? this.buffer('>')
: this.buffer('/>');
// if it is non-empty throw an error
if (tag.block &&
!(tag.block.type === 'Block' && tag.block.nodes.length === 0) &&
tag.block.nodes.some(function (tag) {
return tag.type !== 'Text' || !/^\s*$/.test(tag.val)
})) {
throw errorAtNode(tag, new Error(name + ' is self closing and should not have content.'));
}
} else {
// Optimize attributes buffering
}
if ('pre' == tag.name) this.escape = true;
if (!this.hasCompiledTag) {
if (!this.hasCompiledDoctype && 'html' == name) {
this.visitDoctype();
}
this.hasCompiledTag = true;
}
// pretty print
if (pp && !tag.isInline())
this.prettyIndent(0, true);
if (tag.selfClosing || (!this.xml && selfClosing.indexOf(tag.name) !== -1)) {
this.buffer('<');
bufferName();
this.visitAttributes(tag.attrs, tag.attributeBlocks);
this.terse
? this.buffer('>')
: this.buffer('/>');
// if it is non-empty throw an error
if (tag.block &&
!(tag.block.type === 'Block' && tag.block.nodes.length === 0) &&
tag.block.nodes.some(function (tag) {
return tag.type !== 'Text' || !/^\s*$/.test(tag.val)
})) {
throw errorAtNode(tag, new Error(name + ' is self closing and should not have content.'));
}
} else {
// Optimize attributes buffering
// Set "isInTag" to `true`.
isInTag = true
while (offset++ < contents.length) {
// Stop parsing tag name on first white space or closing tag.
if (/\s|>/.test(contents[offset])) {
isInTag = contents[offset] !== '>'
if (tagname) {
if (isClosingTag) {
if (tags[tags.length - 1] === tagname) {
tags.pop()
}
} else {
if (!voidElements.hasOwnProperty(tagname)) {
tags.push(tagname)
}
}
}
break
}
tagname += contents[offset]
}
} else if (char === '>') {
isInTag = false
} else if (char === '&') {
for (var j = offset; j < contents.length; j++) {
if (WHITESPACE_REGEXP.test(contents[j])) {
break
/**
* Module dependencies.
*/
var indexOf = require('index-of');
var debug = require('debug')('range-normalize');
// map to an Object for faster lookup times
var voidElements = require('void-elements').reduce(function (obj, name) {
obj[name.toUpperCase()] = true;
return obj;
}, {});
/**
* Module exports.
*/
module.exports = normalize;
/**
* "Normalizes" the DOM Range instance, such that slight variations in the start
* and end containers end up being normalized to the same "base" representation.
* The aim is to always have `startContainer` and `endContainer` pointing to
* TextNode instances.
*
var NESTED_FORMATTING_ELEMENTS = inlineElements.filter((el) => (voidElements.indexOf(el) == -1) && el != 'span').map((el) => el + ' ' + el).join(', ');