MarkupParser.parse()method
Parse a text string as Markdownish markup syntax and render it as a React node.
parse(input: string, context = this.context): ReactNode
new MarkupParser({ rules = MARKUP_RULES, rel, url, root, schemes = HTTP_SCHEMES, context = "block" }: MarkupOptions = {})| Param | Type | |
|---|---|---|
options | MarkupOptions | Options configuring a MarkupParser (represents the current state of the parsing). Defaults to {} |
.rules | MarkupRules | The active list of parsing rules. Defaults to MARKUP_RULES readonly |
.rel | string | Set the rel="" property used for any links (e.g. rel="nofollow ugc"). readonly |
.url | ImmutableURL | Current page URL — used as the base for resolving relative refs ( ./foo, #x, bare segments) in link hrefs. readonly |
.root | ImmutableURL | Site root URL — used as the base for resolving site-absolute path hrefs ( /foo), honoring its subfolder. readonly |
.schemes | URISchemes | Valid URI schemes/protocols for URLs and URIs. Defaults to ["http:", "https:"] readonly |
.context | string | Default context to use if one isn't set. Defaults to "block" readonly |
| Return | |
|---|---|
MarkupParser | Parses a Markdownish markup string and renders it as a React node using a tiered, masking rule engine. |
| Property | Type | |
|---|---|---|
.rules | MarkupRules | The list of parsing rules this parser applies. required readonly |
.priorities | ImmutableArray<number> | Calculated list of priorities to iterate over (extracted from the rules), e.g. [10, 0, -10] required readonly |
.rel | string | Set the rel="" property used for any links (e.g. rel="nofollow ugc"). readonly |
.url | ImmutableURL | Current page URL — used as the base for resolving relative refs ( ./foo, #x, bare segments) in link hrefs. Falls back to root if not set. readonly |
.root | ImmutableURL | Site root URL — used as the base for resolving site-absolute path hrefs ( /foo), honoring its subfolder. Falls back to url if not set. readonly |
.schemes | URISchemes | Valid URI schemes/protocols for URLs and URIs. Defaults to ["http:", "https:"] readonly |
.context | string | Default context to use if one isn't set. Defaults to "block" required readonly |
Parses a Markdownish markup string and renders it as a React node using a tiered, masking rule engine.
rules supplied (defaults to MARKUP_RULES).parse() again, optionally with a different context.const node = new MarkupParser().parse("This is a *bold* string.");Parse a text string as Markdownish markup syntax and render it as a React node.
parse(input: string, context = this.context): ReactNode
Yield the rules active in context that sit in the given priority tier.
getRules(context: string, priority: number): Iterable<MarkupRule>
Resolve a link href against this parser's url and root, returning it only if its scheme is allowed.
getLink(href: Nullish<PossibleLink>): ImmutableURI | undefined