@yozora/tokenizer-admonition v2.3.12
@yozora/tokenizer-admonition produce Admonition type nodes. See documentation for details.
Install
npm
npm install --save @yozora/tokenizer-admonition
yarn
yarn add @yozora/tokenizer-admonition
Usage
@yozora/tokenizer-admonition has been integrated into @yozora/parser, so you can use
YozoraParser
directly.
Basic Usage
@yozora/tokenizer-admonition cannot be used alone, it needs to be registered in YastParser as a plugin-in before it can be used.
import { DefaultParser } from '@yozora/core-parser'
import ParagraphTokenizer from '@yozora/tokenizer-paragraph'
import TextTokenizer from '@yozora/tokenizer-text'
import AdmonitionTokenizer from '@yozora/tokenizer-admonition'
const parser = new DefaultParser()
.useFallbackTokenizer(new ParagraphTokenizer())
.useFallbackTokenizer(new TextTokenizer())
.useTokenizer(new AdmonitionTokenizer())
// parse source markdown content
parser.parse(`
:::info this is a info type admonition
waw
### some block contents
:::
`)
Use within @yozora/parser
import YozoraParser from '@yozora/parser'
const parser = new YozoraParser()
// parse source markdown content
parser.parse(`
:::info this is a info type admonition
waw
### some block contents
:::
`)
Use with @yozora/parser-gfm
import GfmParser from '@yozora/parser-gfm'
import AdmonitionTokenizer from '@yozora/tokenizer-admonition'
const parser = new GfmParser()
parser.useTokenizer(new AdmonitionTokenizer())
// parse source markdown content
parser.parse(`
:::info this is a info type admonition
waw
### some block contents
:::
`)
Use within @yozora/parser-gfm-ex
import GfmExParser from '@yozora/parser-gfm-ex'
import AdmonitionTokenizer from '@yozora/tokenizer-admonition'
const parser = new GfmExParser()
parser.useTokenizer(new AdmonitionTokenizer())
// parse source markdown content
parser.parse(`
:::info this is a info type admonition
waw
### some block contents
:::
`)
Options
Name | Type | Required | Default |
---|---|---|---|
name | string | false | "@yozora/tokenizer-admonition" |
priority | number | false | TokenizerPriority.FENCED_BLOCK |
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.
Node Type
export interface Admonition extends Parent<'admonition'> {
type: 'admonition'
/**
* Keyword of an admonition.
*/
keyword: 'note' | 'important' | 'tip' | 'caution' | 'warning' | string
/**
* Admonition title.
*/
title: Node[]
/**
* Admonition body.
*/
children: Node[]
}
Output Example
positions omitted:
{ "type": "admonition", "keyword": "tip", "title": [ { "type": "text", "value": "pro tip" } ], "children": [ { "type": "paragraph", "children": [ { "type": "text", "value": "admonition is awesome!\n" } ] } ] }
Related
16 days ago
2 months ago
2 months ago
3 months ago
3 months ago
4 months ago
5 months ago
6 months ago
5 months ago
6 months ago
9 months ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago