mwbot-ts - v1.2.6
    Preparing search index...

    Interface WikitextStatic

    This interface defines the static members of the Wikitext class. For instance members, see Wikitext (defined separately due to TypeScript limitations).

    This class is accesible via Mwbot.Wikitext.

    interface WikitextStatic {
        new WikitextStatic(content: string): Wikitext;
        getValidTags(): Set<string>;
        isValidTag(tagName: string): boolean;
        new(content: string): Wikitext;
        newFromTitle(
            title: string | Title,
            requestOptions?: MwbotRequestConfig,
        ): Promise<Wikitext>;
    }
    Index

    Constructors

    • Creates a new Wikitext instance.

      Usage:

      const wikitext = new mwbot.Wikitext('Some wikitext');
      

      Parameters

      • content: string

        A wikitext content.

      Returns Wikitext

      If content is not a string.

    Methods

    • Returns a list of valid HTML tag names that can be used in wikitext.

      Returns Set<string>

      Set of tag names (all elements are in lowercase).

    • Checks whether a given tag name is valid in wikitext.

      Parameters

      • tagName: string

        The tag name to check.

      Returns boolean

      A boolean indicating whether the tag name is valid.

    • Alias of the constructor.

      Usage:

      const wikitext = mwbot.Wikitext.new('Some wikitext');
      

      Parameters

      • content: string

        A wikitext content.

      Returns Wikitext

      If content is not a string.

    • Creates a new instance by fetching the content of the given title.

      Example:

      const wikitext = await mwbot.Wikitext.newFromTitle('Foo').catch((err: MwbotError) => err);
      if (wikitext instanceof MwbotError) {
      console.error(wikitext);
      return;
      }
      // Example for parsing the sections of the page 'Foo'
      const sections = wikitext.parseSections();

      Parameters

      • title: string | Title

        The page title, either as a string or a Title instance.

      • OptionalrequestOptions: MwbotRequestConfig

        Optional HTTP request options.

      Returns Promise<Wikitext>

      A Promise resolving to a new Wikitext instance.