Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, function (body) {
var handler = new htmlparser.DefaultHandler()
var tokenizer = new (require('./parser'))
var parser = new htmlparser.Parser(handler);
tokenizer._cbs = new TokenizerProxy(parser._tokenizer._cbs)
parser._tokenizer = tokenizer
parser.parseComplete(body)
//console.log('=======')
// great. now it's time for a serializer.
//console.log( domutils.getOuterHTML(handler.dom[0]))
//console.log('=======')
//console.log(require('util').inspect(handler.dom[0], false, null))
var actual = new (xmldom.DOMParser)().parseFromString('')
actual.documentElement.parentNode.removeChild(actual.documentElement)
createXMLTemplate(actual, handler.dom[0])
// Why? Because. Because namespaces. Hateful namespaces.
var actual = new (xmldom.DOMParser)().parseFromString(actual.toString())
var htmlparser = require("htmlparser2");
var fetchFiles = require('../../../build/html/fetchFiles.js');
var handler = new htmlparser.DefaultHandler();
var parser = new htmlparser.Parser(handler, { lowerCaseTags: true });
function getAst(content){
parser.parseComplete(content);
return handler.dom;
}
function getFlowData(ast, spy){
return {
inputDir: '/some/dir',
inputFile:{
ast: ast
},
files: {
add: spy
},
extractFileTemplates (fileData) {
let templates = []
const handler = new htmlparser.DefaultHandler((error, dom) => {
if (error) {
return console.log(error)
}
const $ = cheerio.load(dom)
templates = templates.concat($('template[lang="pug"]').text())
})
var parser = new htmlparser.Parser(handler)
parser.parseComplete(fileData)
return templates
}
}
extractFileTemplates (fileData) {
let templates = []
const handler = new htmlparser.DefaultHandler((error, dom) => {
if (error) {
return console.log(error)
}
const $ = cheerio.load(dom)
const scssTemplate = $('style[lang="scss"]').text()
const sassTemplate = $('style[lang="sass"]').text()
if (scssTemplate.length) {
templates.push({
content: scssTemplate,
format: 'scss',
lineOffset: this.getLineOffset(scssTemplate, $.text())
})
}
if (sassTemplate.length) {
function html (document, html) {
var handler = new htmlparser.DefaultHandler(),
frag = document.createDocumentFragment();
var parser = new htmlparser.Parser(handler);
parser.parseComplete(html);
copy(document, frag, handler.dom);
return frag;
}
noAnchorUrl: true,
baseElement: 'body',
returnDomByDefault: true,
format: {},
decodeOptions: {
isAttributeValue: false,
strict: false
},
longWordSplit: {
wrapCharacters: [],
forceWrapOnLimit: false
},
unorderedListItemPrefix: ' * '
}, options || {});
var handler = new htmlparser.DefaultHandler(function (error, dom) {
}, {
verbose: true
});
new htmlparser.Parser(handler).parseComplete(html);
options.lineCharCount = 0;
var result = '';
var baseElements = Array.isArray(options.baseElement) ? options.baseElement : [options.baseElement];
for (var idx = 0; idx < baseElements.length; ++idx) {
result += walk(filterBody(handler.dom, options, baseElements[idx]), options);
}
return trimEnd(result);
}
Hocr.prototype.parse = function() {
var handler, parser, that;
that = this;
handler = new htmlparser.DefaultHandler(function(error, dom) {
if (error) {
return that.callback(error, false);
} else {
that.toJSON(dom);
return that.callback(false, that.result);
}
}, {
verbose: false,
ignoreWhitespace: true
});
parser = new htmlparser.Parser(handler);
return parser.parseComplete(this.html);
};