All files / prettyhtml-rehype-webparser/dist index.js

61.54% Statements 8/13
88.89% Branches 8/9
50% Functions 2/4
61.54% Lines 8/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37  1x 1x   1x 1x 1x 1x 1x 1x                                                      
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
const webparser_1 = require("@starptech/webparser");
const hast_util_from_webparser_1 = __importDefault(require("@starptech/hast-util-from-webparser"));
const VMessage = require('vfile-message');
module.exports = function parse(options) {
    options = options || {};
    this.Parser = parser;
    function parser(doc, file) {
        const parseResult = new webparser_1.HtmlParser({
            ignoreFirstLf: false,
            decodeEntities: false,
            selfClosingCustomElements: true
        }).parse(doc, file.path);
        for (const err of parseResult.errors) {
            file.message(createVMessage(err));
        }
        return hast_util_from_webparser_1.default(parseResult.rootNodes, options);
    }
    function createVMessage(err) {
        return new VMessage(err.contextualMessage(), {
            start: {
                line: err.span.start.line,
                offset: err.span.start.offset,
                column: err.span.start.col
            },
            end: {
                line: err.span.end.line,
                offset: err.span.end.offset,
                column: err.span.end.col
            }
        }, 'ParseError');
    }
};
//# sourceMappingURL=index.js.map