UNPKG

hackmd-to-html-cli

Version:

A node.js CLI tool for converting HackMD markdown to HTML.

73 lines 1.95 kB
"use strict"; // Because markdown-it does not export the Token class, // we can implement the class ourselves. // token.ts was modified from // https://github.com/markdown-it/markdown-it/blob/0fe7ccb4b7f30236fb05f623be6924961d296d3d/lib/token.mjs#L12 Object.defineProperty(exports, "__esModule", { value: true }); exports.MyToken = void 0; class MyToken { constructor(type, tag, nesting) { this.type = type; this.tag = tag; this.attrs = null; this.map = null; this.nesting = nesting; this.level = 0; this.children = null; this.content = ''; this.markup = ''; this.info = ''; this.meta = null; this.block = false; this.hidden = false; } attrIndex(name) { if (!this.attrs) { return -1; } const attrs = this.attrs; for (let i = 0, len = attrs.length; i < len; i++) { if (attrs[i][0] === name) { return i; } } return -1; } attrPush(attrData) { if (this.attrs) { this.attrs.push(attrData); } else { this.attrs = [attrData]; } } attrSet(name, value) { const idx = this.attrIndex(name); const attrData = [name, value]; if (idx < 0) { this.attrPush(attrData); } else { this.attrs[idx] = attrData; } } attrGet(name) { const idx = this.attrIndex(name); let value = null; if (idx >= 0) { value = this.attrs[idx][1]; } return value; } attrJoin(name, value) { const idx = this.attrIndex(name); if (idx < 0) { this.attrPush([name, value]); } else { this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value; } } } exports.MyToken = MyToken; //# sourceMappingURL=token.js.map