Class BBCodeLibrary

This is the BBCodeLibrary class, it is responsible for defining the default Emoji, the default tags, and providing the functions to parse the default tags. You can extend this Library and pass it to BBCode when creating it, or create new tags using the addRule function.

Hierarchy

  • BBCodeLibrary

Constructors

Properties

defaultEmoji: Record<string, string> = ...

Var

defaultEmoji Standard library of Emoji definitions.

defaultTagRules: Record<string, TagRules> = ...

Var

defaultTagRules TagRules Standard rules for what to do when a BBCode tag is encountered.

imageExtensions: string[] = ...

Var

array The file extensions that are considered valid local images.

Methods

  • Format an [email] tag by producing an ... element.

    The e-mail address must be a valid address including at least a '@' and a valid domain name or IPv4 or IPv6 address after the '@'.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string | true

    string Returns the email link HTML.

  • Format a [font] tag by producing a with a style with a different font-family.

    This is complicated by the fact that we have to recognize the five special font names and quote all the others.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string

    Returns a span with the font family CSS.

  • Format an [img] tag. The URL only allows http, https, and ftp protocols for safety.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string | true

    Returns the image tag.

  • Format a [list] tag.

    This is complicated by the number of different ways a list can be started. The following parameters are allowed:

    [list]           Unordered list, using default marker
    [list=circle] Unordered list, using circle marker
    [list=disc] Unordered list, using disc marker
    [list=square] Unordered list, using square marker

    [list=1] Ordered list, numeric, starting at 1
    [list=A] Ordered list, capital letters, starting at A
    [list=a] Ordered list, lowercase letters, starting at a
    [list=I] Ordered list, capital Roman numerals, starting at I
    [list=i] Ordered list, lowercase Roman numerals, starting at i
    [list=greek] Ordered list, lowercase Greek letters, starting at alpha
    [list=01] Ordered list, two-digit numeric with 0-padding, starting at 01

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string | boolean

    Returns the list HTML or a boolen result when action is BBAction.BBCODE_CHECK.

  • Format a [quote] tag.

    This tag can come in a variety of flavors:

    [quote]...[/quote]
    [quote=Tom]...[/quote]
    [quote name="Tom"]...[/quote]

    In the third form, you can also add a date="" parameter to display the date on which Tom wrote it, and you can add a url="" parameter to turn the author's name into a link. A full example might be:

    [quote name="Tom" date="July 4, 1776 3:48 PM" url="http://www.constitution.gov"]...[/quote]
    

    The URL only allows http, https, mailto, gopher, ftp, and feed protocols for safety.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string | boolean

    Returns the quote HTML or true if action is BBAction.BBCODE_CHECK.

  • Format a [rule] tag.

    This substitutes the content provided by the BBCode object, whatever that may be.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string | boolean

    Returns the rule HTML or true if action is BBAction.BBCODE_CHECK.

  • Format a [size] tag by producing a with a style with a different font-size.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string

    Returns a span with the font size CSS.

  • Format a [url] tag by producing an ... element.

    The URL only allows http, https, mailto, and ftp protocols for safety.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string | true

    Returns the full HTML url.

  • Format a [wiki] tag by producing an ... element.

    Parameters

    • bbcode: BBCode
    • action: BBEnum.BBAction

      The current action being performed on the tag.

    • name: string

      The name of the tag.

    • defaultValue: string

      The default value passed to the tag in the form: [tag=default].

    • params: TagType

      All of the parameters passed to the tag.

    • content: string

      The content of the tag. Only available when action is OUTPUT.

    Returns string | boolean

    Returns a link to the wiki.

Generated using TypeDoc