"use strict";
const htmlparser = require("htmlparser2");
function iterateCode (source, onStyleTag, onStyleAttribute) {
let currentStyle = null;
let level = 0;
let isFirstTag = true;
function onFirstTag () {
// Found a tag, the structure is now confirmed as HTML
if (isFirstTag) {
if (parser.startIndex <= 0 || !source.slice(0, parser.startIndex).trim()) {
level = 2;
}
isFirstTag = false;
}
}
const parser = new htmlparser.Parser({
oncomment: onFirstTag,
onprocessinginstruction: onFirstTag,
onopentag (name, attribute) {
onFirstTag();
if (!level) {
level = 1;
}
// Test if current tag is a valid