Skip to main content

Matcher <Props, Options>

Implements

Index

Constructors

constructor

  • new Matcher<Props, Options>(name: string, options?: Options, factory?: null | ComponentType<Props>): Matcher<Props, Options>
  • Type parameters

    • Props: object = {}
    • Options: object = {}

Properties

factory

factory: null | ComponentType<Props>

greedy

greedy: boolean = false

inverseName

inverseName: string

options

options: Options

propName

propName: string

Methods

abstractasTag

  • asTag(): string
  • Defines the HTML tag name that the resulting React element will be.

createElement

  • Attempts to create a React element using a custom user provided factory, or the default matcher factory.

doMatch

  • Trigger the actual pattern match and package the matched response through a callback.


    Type parameters

    • T

abstractmatch

  • match(string: string): any
  • Attempt to match against the defined string. Return null if no match found, else return the match and any optional props to pass along.

onAfterParse

  • onAfterParse(content: Node[], props: Props): Node[]
  • Callback triggered after parsing.

onBeforeParse

  • onBeforeParse(content: string, props: Props): string
  • Callback triggered before parsing.

abstractreplaceWith

  • Replace the match with a React element based on the matched token and optional props.