UNPKG

vue-files-preview-inno

Version:

A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.

1 lines 5.35 kB
{"version":3,"file":"token.mjs","sources":["../../../../../node_modules/markdown-it/lib/token.mjs"],"sourcesContent":["// Token class\n\n/**\n * class Token\n **/\n\n/**\n * new Token(type, tag, nesting)\n *\n * Create new token and fill passed properties.\n **/\nfunction Token (type, tag, nesting) {\n /**\n * Token#type -> String\n *\n * Type of the token (string, e.g. \"paragraph_open\")\n **/\n this.type = type\n\n /**\n * Token#tag -> String\n *\n * html tag name, e.g. \"p\"\n **/\n this.tag = tag\n\n /**\n * Token#attrs -> Array\n *\n * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`\n **/\n this.attrs = null\n\n /**\n * Token#map -> Array\n *\n * Source map info. Format: `[ line_begin, line_end ]`\n **/\n this.map = null\n\n /**\n * Token#nesting -> Number\n *\n * Level change (number in {-1, 0, 1} set), where:\n *\n * - `1` means the tag is opening\n * - `0` means the tag is self-closing\n * - `-1` means the tag is closing\n **/\n this.nesting = nesting\n\n /**\n * Token#level -> Number\n *\n * nesting level, the same as `state.level`\n **/\n this.level = 0\n\n /**\n * Token#children -> Array\n *\n * An array of child nodes (inline and img tokens)\n **/\n this.children = null\n\n /**\n * Token#content -> String\n *\n * In a case of self-closing tag (code, html, fence, etc.),\n * it has contents of this tag.\n **/\n this.content = ''\n\n /**\n * Token#markup -> String\n *\n * '*' or '_' for emphasis, fence string for fence, etc.\n **/\n this.markup = ''\n\n /**\n * Token#info -> String\n *\n * Additional information:\n *\n * - Info string for \"fence\" tokens\n * - The value \"auto\" for autolink \"link_open\" and \"link_close\" tokens\n * - The string value of the item marker for ordered-list \"list_item_open\" tokens\n **/\n this.info = ''\n\n /**\n * Token#meta -> Object\n *\n * A place for plugins to store an arbitrary data\n **/\n this.meta = null\n\n /**\n * Token#block -> Boolean\n *\n * True for block-level tokens, false for inline tokens.\n * Used in renderer to calculate line breaks\n **/\n this.block = false\n\n /**\n * Token#hidden -> Boolean\n *\n * If it's true, ignore this element when rendering. Used for tight lists\n * to hide paragraphs.\n **/\n this.hidden = false\n}\n\n/**\n * Token.attrIndex(name) -> Number\n *\n * Search attribute index by name.\n **/\nToken.prototype.attrIndex = function attrIndex (name) {\n if (!this.attrs) { return -1 }\n\n const attrs = this.attrs\n\n for (let i = 0, len = attrs.length; i < len; i++) {\n if (attrs[i][0] === name) { return i }\n }\n return -1\n}\n\n/**\n * Token.attrPush(attrData)\n *\n * Add `[ name, value ]` attribute to list. Init attrs if necessary\n **/\nToken.prototype.attrPush = function attrPush (attrData) {\n if (this.attrs) {\n this.attrs.push(attrData)\n } else {\n this.attrs = [attrData]\n }\n}\n\n/**\n * Token.attrSet(name, value)\n *\n * Set `name` attribute to `value`. Override old value if exists.\n **/\nToken.prototype.attrSet = function attrSet (name, value) {\n const idx = this.attrIndex(name)\n const attrData = [name, value]\n\n if (idx < 0) {\n this.attrPush(attrData)\n } else {\n this.attrs[idx] = attrData\n }\n}\n\n/**\n * Token.attrGet(name)\n *\n * Get the value of attribute `name`, or null if it does not exist.\n **/\nToken.prototype.attrGet = function attrGet (name) {\n const idx = this.attrIndex(name)\n let value = null\n if (idx >= 0) {\n value = this.attrs[idx][1]\n }\n return value\n}\n\n/**\n * Token.attrJoin(name, value)\n *\n * Join value to existing attribute via space. Or create new attribute if not\n * exists. Useful to operate with token classes.\n **/\nToken.prototype.attrJoin = function attrJoin (name, value) {\n const idx = this.attrIndex(name)\n\n if (idx < 0) {\n this.attrPush([name, value])\n } else {\n this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value\n }\n}\n\nexport default Token\n"],"names":["Token","type","tag","nesting","name","attrs","i","len","attrData","value","idx"],"mappings":"AAWA,SAASA,EAAOC,GAAMC,GAAKC,GAAS;AAMlC,OAAK,OAAWF,GAOhB,KAAK,MAAWC,GAOhB,KAAK,QAAW,MAOhB,KAAK,MAAW,MAWhB,KAAK,UAAWC,GAOhB,KAAK,QAAW,GAOhB,K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