/** * Class for some basic wikitext parsing, involving * links, files, categories, templates and simple tables * and sections. * * For more advanced and sophisticated wikitext parsing, use * mwparserfromhell * implemented in python (which you can use within node.js using * the child_process interface). However, mwparserfromhell doesn't * recognize localised namespaces and wiki-specific configs. * * This class is for methods for parsing wikitext, for the * static methods for creating wikitext, see static_utils.js. */ import type { Mwn } from './bot'; import type { MwnTitle } from './title'; import type { ApiParseParams } from 'types-mediawiki-api'; export interface MwnWikitextStatic { new (text: string): MwnWikitext; /** Static version of {@link MwnWikitext.parseTemplates} */ parseTemplates(wikitext: string, config: TemplateConfig): Template[]; /** * Simple table parser. * Parses tables provided: * 1. It doesn't have any merged or joined cells. * 2. It doesn't use any templates to produce any table markup. * 3. Further restrictions may apply. * * Tables generated via mwn.Table() class are intended to be parsable. * * This method throws when it finds an inconsistency (rather than silently * cause undesired behaviour). * * @param {string} text * @returns {Object[]} - each object in the returned array represents a row, * with its keys being column names, and values the cell content */ parseTable(text: string): { [column: string]: string; }[]; /** Static version of {@link MwnWikitext.parseSections} */ parseSections(text: string): Section[]; } export interface MwnWikitext extends Unbinder { links: Array; templates: Array