@yozora/tokenizer-footnote-definition
Installโ
- npm
- Yarn
- pnpm
npm install --save @yozora/tokenizer-footnote-definition
yarn add @yozora/tokenizer-footnote-definition
pnpm add @yozora/tokenizer-footnote-definition
Usageโ
@yozora/tokenizer-footnote-definition has been integrated into @yozora/parser,
so you can use YozoraParser
directly.
- Basic Usage
- YozoraParser
- GfmParser
- GfmExParser
@yozora/tokenizer-footnote-definition cannot be used alone, it needs to be registered in YastParser as a plugin-in before it can be used.
import { DefaultYastParser } from '@yozora/core-parser'
import ParagraphTokenizer from '@yozora/tokenizer-paragraph'
import TextTokenizer from '@yozora/tokenizer-text'
import FootnoteDefinitionTokenizer from '@yozora/tokenizer-footnote-definition'
const parser = new DefaultYastParser()
.useBlockFallbackTokenizer(new ParagraphTokenizer())
.useInlineFallbackTokenizer(new TextTokenizer())
.useTokenizer(new FootnoteDefinitionTokenizer())
// parse source markdown content
parser.parse(`
Here is a footnote reference,[^1]
another,[^long note],
[^big footnote]: Here's one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
\`\`\`
Fenced coding
\`\`\`
## heading
Add as many paragraphs as you like.
`)
import YozoraParser from '@yozora/parser'
const parser = new YozoraParser()
// parse source markdown content
parser.parse(`
Here is a footnote reference,[^1]
another,[^long note],
[^big footnote]: Here's one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
\`\`\`
Fenced coding
\`\`\`
## heading
Add as many paragraphs as you like.
`)
FootnoteDefinitionTokenizer
should take precedence over DefinitionTokenizer
.
import GfmParser from '@yozora/parser-gfm'
import { DefinitionTokenizerName } from '@yozora/tokenizer-definition'
import FootnoteDefinitionTokenizer from '@yozora/tokenizer-footnote-definition'
const parser = new GfmParser()
parser.useTokenizer(new FootnoteDefinitionTokenizer(), DefinitionTokenizerName)
// parse source markdown content
parser.parse(`
Here is a footnote reference,[^1]
another,[^long note],
[^big footnote]: Here's one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
\`\`\`
Fenced coding
\`\`\`
## heading
Add as many paragraphs as you like.
`)
FootnoteDefinitionTokenizer
should take precedence over DefinitionTokenizer
.
import GfmExParser from '@yozora/parser-gfm-ex'
import { DefinitionTokenizerName } from '@yozora/tokenizer-definition'
import FootnoteDefinitionTokenizer from '@yozora/tokenizer-footnote-definition'
const parser = new GfmExParser()
parser.useTokenizer(new FootnoteDefinitionTokenizer(), DefinitionTokenizerName)
// parse source markdown content
parser.parse(`
Here is a footnote reference,[^1]
another,[^long note],
[^big footnote]: Here's one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
\`\`\`
Fenced coding
\`\`\`
## heading
Add as many paragraphs as you like.
`)
Optionsโ
Name | Type | Required | Default |
---|---|---|---|
name | string | false | "@yozora/tokenizer-footnote-definition" |
priority | number | false | TokenizerPriority.ATOMIC |
-
name
: The unique name of the tokenizer, used to bind the token it generates, to determine the tokenizer that should be called in each life cycle of the token in the entire matching / parsing phase. -
priority
: Priority of the tokenizer, determine the order of processing, high priority priority execution. interruptable. In addition, in thematch-block
stage, a high-priority tokenizer can interrupt the matching process of a low-priority tokenizer.
Typesโ
@yozora/tokenizer-footnote-definition produce FootnoteDefinition type nodes. See @yozora/ast for full base types.
import type { YastAssociation, YastParent } from '@yozora/ast'
export const FootnoteDefinitionType = 'footnoteDefinition'
export type FootnoteDefinitionType = typeof FootnoteDefinitionType
/**
* FootnoteDefinition represents content relating to the document that is
* outside its flow.
* @see https://github.com/syntax-tree/mdast#footnotedefinition
*/
export interface FootnoteDefinition
extends YastParent<FootnoteDefinitionType>, YastAssociation {}