Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setNodeData(node, 'indentLevel', level - 1)
// clear empty script, textarea, pre, style tags
if (length) {
const empty = hasOnlyEmptyTextChildren(node)
const isEmbeddedContent = isElement(node, 'style') || isElement(node, 'script')
if (empty) {
// eslint-disable-next-line no-param-reassign
node.children = []
}
if (usePrettier && !empty && isEmbeddedContent) {
prettierEmbeddedContent(node, level, indent, prettierOpts)
}
}
return visit.SKIP
}
let newline = false
// we have to look in the future because we indent leading text
// on a newline when a child text node contains a newline. If we wouldn't do this
// the formatter could produce an unstable result because in the next step we could produce newlines.
const collpased = peekCollpase(node, children)
/**
* Indent children
*/
index = -1
while (++index < length) {
// eslint-disable-next-line no-shadow
const child = children[index]
'use strict'
module.exports = visit
var visitParents = require('unist-util-visit-parents')
var CONTINUE = visitParents.CONTINUE
var SKIP = visitParents.SKIP
var EXIT = visitParents.EXIT
visit.CONTINUE = CONTINUE
visit.SKIP = SKIP
visit.EXIT = EXIT
function visit(tree, test, visitor, reverse) {
if (typeof test === 'function' && typeof visitor !== 'function') {
reverse = visitor
visitor = test
test = null
}
visitParents(tree, test, overload, reverse)
function overload(node, parents) {
function setAttributeOnChildren(node, parents, attributeName, attributeValue) {
const parent = parents[parents.length - 1]
const nodeIndex = parent ? parent.children.indexOf(node) : null
if (nodeIndex !== null) {
for (let i = nodeIndex; i < parent.children.length; i++) {
const child = parent.children[i]
if (isElement(child)) {
setNodeData(child, attributeName, attributeValue)
return visit.SKIP
}
}
}
}