const { parse } = require('@test/test-target');
const { HTMLElement } = require('@test/test-target');
// https://github.com/taoqf/node-html-parser/issues/77
describe('pre tag', function () {
it('should parse pre tag correctly', function () {
const html = `
`;
const root = parse(html, {
blockTextElements: {
script: true,
noscript: true,
style: true,
pre: true
}
});
root.toString().should.eql(html);
});
it('should ignore pre tag', function () {
const html = ``;
const root = parse(html, {
blockTextElements: {
pre: true
}
});
const div = root.firstChild.firstChild;
const pre = div.firstChild;
pre.text.should.eql(`print('hello')
i = i + 1
`);
});
it('do not treat pre as text block element', function () {
const html = `
`;
const root = parse(html, {
blockTextElements: {}
});
const div = root.firstChild.firstChild;
const pre = div.firstChild;
const code = pre.firstChild;
code.childNodes.length.should.eql(11);
});
// see: https://github.com/taoqf/node-html-parser/issues/156
it('does not treat pre* tag as pre (partial match)', () => {
const docRoot = parse("Red");
Object.getPrototypeOf(docRoot.firstChild.firstChild).should.eql(HTMLElement.prototype);
docRoot.firstChild.firstChild.tagName.should.eql('COLOR');
})
});