UNPKG

wikiparser-node

Version:

A Node.js parser for MediaWiki markup with AST

193 lines (192 loc) 5.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.obsoleteAttrs = exports.extAttrs = exports.htmlAttrs = exports.commonHtmlAttrs = void 0; /* eslint-disable unicorn/no-unreadable-iife */ const blockAttrs = new Set(['align']), citeAttrs = new Set(['cite']), citeAndAttrs = new Set(['cite', 'datetime']), widthAttrs = new Set(['width']), obsoleteTdAttrs = new Set(['axis', 'align', 'bgcolor', 'height', 'width', 'valign']), tdAttrs = new Set([...obsoleteTdAttrs, 'abbr', 'headers', 'scope', 'rowspan', 'colspan']), typeAttrs = new Set(['type']), obsoleteTableAttrs = new Set(['summary', 'align', 'bgcolor', 'cellpadding', 'cellspacing', 'frame', 'rules', 'width']), brAttrs = new Set(['clear']), trAttrs = new Set(['bgcolor', 'align', 'valign']), chemAttrs = new Set(['qid', 'forcemathmode', 'type', 'display']), syntaxHighlightAttrs = new Set([ 'enclose', 'inline', 'lang', 'line', 'linelinks', 'style', 'class', 'id', 'dir', 'copy', 'highlight', 'start', ]), empty = new Set(); exports.commonHtmlAttrs = 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', ]), exports.htmlAttrs = (() => ({ 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: new Set(['type', 'start', 'reversed']), li: new Set(['type', 'value']), table: new Set([...obsoleteTableAttrs, 'border']), caption: blockAttrs, tr: trAttrs, td: tdAttrs, th: tdAttrs, font: new Set(['size', 'color', 'face']), hr: widthAttrs, data: new Set(['value']), time: new Set(['datetime']), meta: new Set(['itemprop', 'content']), link: new Set(['itemprop', 'href', 'title']), gallery: typeAttrs, poem: blockAttrs, categorytree: blockAttrs, combooption: blockAttrs, math: empty, chem: empty, ce: empty, img: new Set(['alt', 'src', 'width', 'height', 'loading', 'srcset']), }))(), exports.extAttrs = (() => ({ gallery: new Set(['mode', 'showfilename', 'caption', 'perrow', 'widths', 'heights', 'showthumbnails']), poem: new Set(['compact']), categorytree: new Set([ 'hideroot', 'onlyroot', 'depth', 'mode', 'hideprefix', 'namespaces', 'showcount', 'notranslations', ]), combooption: new Set(['name', 'for', 'inline']), nowiki: empty, indicator: new Set(['name']), langconvert: new Set(['from', 'to']), ref: new Set(['group', 'name', 'follow', 'dir', 'details']), references: new Set(['group', 'responsive']), charinsert: new Set(['label']), choose: new Set(['uncached', 'before', 'after']), option: new Set(['weight']), imagemap: empty, inputbox: empty, templatestyles: new Set(['src', 'wrapper']), dynamicpagelist: empty, poll: new Set(['id', 'show-results-before-voting']), sm2: typeAttrs, flashmp3: typeAttrs, score: new Set([ 'line_width_inches', 'lang', 'override_midi', 'raw', 'note-language', 'override_audio', 'override_ogg', 'sound', 'vorbis', ]), seo: 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: new Set([ 'nested', 'name', 'index', 'class', 'block', 'inline', 'openname', 'closename', 'collapsed', 'dropdown', 'style', 'bgcolor', 'container', 'id', 'title', ]), tabs: new Set(['plain', 'class', 'container', 'id', 'title', 'style']), combobox: new Set(['placeholder', 'value', 'id', 'class', 'text', 'dropdown', 'style']), math: new Set([...chemAttrs, 'chem']), chem: chemAttrs, ce: chemAttrs, hiero: empty, phonos: new Set(['ipa', 'class', 'text', 'lang', 'wikibase', 'file']), section: new Set(['begin', 'end']), source: syntaxHighlightAttrs, syntaxhighlight: syntaxHighlightAttrs, templatedata: empty, timeline: new Set(['method', 'font']), quiz: new Set(['display', 'shuffleanswers', 'points', 'shuffle', 'case']), languages: empty, }))(), exports.obsoleteAttrs = (() => ({ table: obsoleteTableAttrs, td: 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, }))();