@yozora/tokenizer-footnote
Installโ
- npm
- Yarn
- pnpm
npm install --save @yozora/tokenizer-footnote
yarn add @yozora/tokenizer-footnote
pnpm add @yozora/tokenizer-footnote
Usageโ
@yozora/tokenizer-footnote has been integrated into @yozora/parser,
so you can use YozoraParser
directly.
- Basic Usage
- YozoraParser
- GfmParser
- GfmExParser
@yozora/tokenizer-footnote 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 FootnoteTokenizer from '@yozora/tokenizer-footnote'
const parser = new DefaultYastParser()
.useBlockFallbackTokenizer(new ParagraphTokenizer())
.useInlineFallbackTokenizer(new TextTokenizer())
.useTokenizer(new FootnoteTokenizer())
// parse source markdown content
parser.parse(`
^[inline footnote]
^[footnote with *emphasis* and $x^2+y^2$ and `inline code`]
`)
import YozoraParser from '@yozora/parser'
const parser = new YozoraParser()
// parse source markdown content
parser.parse(`
^[inline footnote]
^[footnote with *emphasis* and $x^2+y^2$ and `inline code`]
`)
import GfmParser from '@yozora/parser-gfm'
import FootnoteTokenizer from '@yozora/tokenizer-footnote'
const parser = new GfmParser()
parser.useTokenizer(new FootnoteTokenizer())
// parse source markdown content
parser.parse(`
^[inline footnote]
^[footnote with *emphasis* and $x^2+y^2$ and `inline code`]
`)
import GfmExParser from '@yozora/parser-gfm-ex'
import FootnoteTokenizer from '@yozora/tokenizer-footnote'
const parser = new GfmExParser()
parser.useTokenizer(new FootnoteTokenizer())
// parse source markdown content
parser.parse(`
^[inline footnote]
^[footnote with *emphasis* and $x^2+y^2$ and `inline code`]
`)
Optionsโ
Name | Type | Required | Default |
---|---|---|---|
name | string | false | "@yozora/tokenizer-footnote" |
priority | number | false | TokenizerPriority.LINKS |
-
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.Exception: Delimiters of type
full
are always processed before other type delimiters.
Typesโ
@yozora/tokenizer-footnote produce Footnote type nodes. See @yozora/ast for full base types.
import type { YastParent } from '@yozora/ast'
export const FootnoteType = 'footnote'
export type FootnoteType = typeof FootnoteType
/**
* Footnote represents content relating to the document that is outside its flow.
* @see https://github.com/syntax-tree/mdast#footnote
*/
export type Footnote = YastParent<FootnoteType>