MarkupParser.nested()method
Return a copy of this parser with depth incremented by one, sharing all other options.
nested(): MarkupParser
new MarkupParser({ rules = MARKUP_RULES, rel, url, root, schemes = HTTP_SCHEMES, context = "block", depth = 0 }: 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 |
.depth | number | Current nesting depth — used to cap self-recursive rules (e.g. blockquotes) so pathological input can't overflow the stack. Internal: set automatically as rules recurse via MarkupParser.nested(); callersnormally leave it at the default 0. Defaults to 0 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 |
.depth | number | Current nesting depth, incremented by nested() as self-recursive rules descend. Used to cap recursion sopathological input (e.g. a long >>>>… blockquote) can't overflow the stack. 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.Return a copy of this parser with depth incremented by one, sharing all other options.
nested(): MarkupParser
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