@xcrap/parser
Version:
Xcrap Parser is a package of the Xcrap framework, it was developed to take care of the data extraction part of text files (currently supporting only HTML and JSON) using declarative models.
18 lines (17 loc) • 818 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MarkdownParsingModel = void 0;
const he_1 = __importDefault(require("he"));
const html_1 = require("../html");
const constants_1 = require("./constants");
class MarkdownParsingModel extends html_1.HtmlParsingModel {
parse(source) {
const htmlSource = constants_1.markdownIt.render(source);
const decodedSource = he_1.default.decode(htmlSource).replace(/\u00A0/g, " ");
return super.parse(`<!DOCTYPE html><html lang="en"><head><title>Markdown Document</title></head><body>${decodedSource}</body></html>`);
}
}
exports.MarkdownParsingModel = MarkdownParsingModel;