UNPKG

wikiparser-node

Version:

A Node.js parser for MediaWiki markup with AST

197 lines (196 loc) 5.64 kB
const blockAttrs = /* @__PURE__ */ new Set(["align"]), citeAttrs = /* @__PURE__ */ new Set(["cite"]), citeAndAttrs = /* @__PURE__ */ new Set(["cite", "datetime"]), widthAttrs = /* @__PURE__ */ new Set(["width"]), obsoleteTdAttrs = /* @__PURE__ */ new Set(["axis", "align", "bgcolor", "height", "width", "valign"]), tdAttrs = /* @__PURE__ */ new Set([...obsoleteTdAttrs, "abbr", "headers", "scope", "rowspan", "colspan"]), typeAttrs = /* @__PURE__ */ new Set(["type"]), obsoleteTableAttrs = /* @__PURE__ */ new Set( ["summary", "align", "bgcolor", "cellpadding", "cellspacing", "frame", "rules", "width"] ), brAttrs = /* @__PURE__ */ new Set(["clear"]), trAttrs = /* @__PURE__ */ new Set(["bgcolor", "align", "valign"]), chemAttrs = /* @__PURE__ */ new Set(["qid", "forcemathmode", "type", "display"]), syntaxHighlightAttrs = /* @__PURE__ */ new Set([ "enclose", "inline", "lang", "line", "linelinks", "style", "class", "id", "dir", "copy", "highlight", "start" ]), empty = /* @__PURE__ */ new Set(); const commonHtmlAttrs = /* @__PURE__ */ new Set([ "id", "class", "style", "lang", "dir", "title", "tabindex", "aria-describedby", "aria-flowto", "aria-hidden", "aria-label", "aria-labelledby", "aria-level", "aria-owns", "role", "about", "property", "resource", "datatype", "typeof", "itemid", "itemprop", "itemref", "itemscope", "itemtype" ]), htmlAttrs = /* @__PURE__ */ (() => ({ div: blockAttrs, h1: blockAttrs, h2: blockAttrs, h3: blockAttrs, h4: blockAttrs, h5: blockAttrs, h6: blockAttrs, blockquote: citeAttrs, q: citeAttrs, p: blockAttrs, br: brAttrs, pre: widthAttrs, ins: citeAndAttrs, del: citeAndAttrs, ul: typeAttrs, ol: /* @__PURE__ */ new Set(["type", "start", "reversed"]), li: /* @__PURE__ */ new Set(["type", "value"]), table: /* @__PURE__ */ new Set([...obsoleteTableAttrs, "border"]), caption: blockAttrs, tr: trAttrs, td: tdAttrs, th: tdAttrs, font: /* @__PURE__ */ new Set(["size", "color", "face"]), hr: widthAttrs, data: /* @__PURE__ */ new Set(["value"]), time: /* @__PURE__ */ new Set(["datetime"]), meta: /* @__PURE__ */ new Set(["itemprop", "content"]), link: /* @__PURE__ */ new Set(["itemprop", "href", "title"]), gallery: typeAttrs, poem: blockAttrs, categorytree: blockAttrs, combooption: blockAttrs, math: empty, chem: empty, ce: empty, img: /* @__PURE__ */ new Set(["alt", "src", "width", "height", "loading", "srcset"]) }))(), extAttrs = /* @__PURE__ */ (() => ({ gallery: /* @__PURE__ */ new Set(["mode", "showfilename", "caption", "perrow", "widths", "heights", "showthumbnails"]), poem: /* @__PURE__ */ new Set(["compact"]), categorytree: /* @__PURE__ */ new Set([ "hideroot", "onlyroot", "depth", "mode", "hideprefix", "namespaces", "showcount", "notranslations" ]), combooption: /* @__PURE__ */ new Set(["name", "for", "inline"]), nowiki: empty, indicator: /* @__PURE__ */ new Set(["name"]), langconvert: /* @__PURE__ */ new Set(["from", "to"]), ref: /* @__PURE__ */ new Set(["group", "name", "follow", "dir", "details"]), references: /* @__PURE__ */ new Set(["group", "responsive"]), charinsert: /* @__PURE__ */ new Set(["label"]), choose: /* @__PURE__ */ new Set(["uncached", "before", "after"]), option: /* @__PURE__ */ new Set(["weight"]), imagemap: empty, inputbox: empty, templatestyles: /* @__PURE__ */ new Set(["src", "wrapper"]), dynamicpagelist: empty, poll: /* @__PURE__ */ new Set(["id", "show-results-before-voting"]), sm2: typeAttrs, flashmp3: typeAttrs, score: /* @__PURE__ */ new Set([ "line_width_inches", "lang", "override_midi", "raw", "note-language", "override_audio", "override_ogg", "sound", "vorbis" ]), seo: /* @__PURE__ */ new Set([ "title", "title_mode", "title_separator", "keywords", "description", "robots", "google_bot", "image", "image_width", "image_height", "image_alt", "type", "site_name", "locale", "section", "author", "published_time", "twitter_site" ]), tab: /* @__PURE__ */ new Set([ "nested", "name", "index", "class", "block", "inline", "openname", "closename", "collapsed", "dropdown", "style", "bgcolor", "container", "id", "title" ]), tabs: /* @__PURE__ */ new Set(["plain", "class", "container", "id", "title", "style"]), combobox: /* @__PURE__ */ new Set(["placeholder", "value", "id", "class", "text", "dropdown", "style"]), math: /* @__PURE__ */ new Set([...chemAttrs, "chem"]), chem: chemAttrs, ce: chemAttrs, hiero: empty, phonos: /* @__PURE__ */ new Set(["ipa", "class", "text", "lang", "wikibase", "file"]), section: /* @__PURE__ */ new Set(["begin", "end"]), source: syntaxHighlightAttrs, syntaxhighlight: syntaxHighlightAttrs, templatedata: empty, timeline: /* @__PURE__ */ new Set(["method", "font"]), quiz: /* @__PURE__ */ new Set(["display", "shuffleanswers", "points", "shuffle", "case"]), languages: empty }))(), obsoleteAttrs = /* @__PURE__ */ (() => ({ table: obsoleteTableAttrs, td: /* @__PURE__ */ new Set([...obsoleteTdAttrs, "scope"]), th: obsoleteTdAttrs, br: brAttrs, caption: blockAttrs, div: blockAttrs, hr: widthAttrs, h1: blockAttrs, h2: blockAttrs, h3: blockAttrs, h4: blockAttrs, h5: blockAttrs, h6: blockAttrs, li: typeAttrs, p: blockAttrs, pre: widthAttrs, tr: trAttrs, ul: typeAttrs }))(); export { commonHtmlAttrs, extAttrs, htmlAttrs, obsoleteAttrs };