@yozora/tokenizer-heading
v2.3.1
Published
<!-- :begin use tokenizer/banner -->
Downloads
65
Readme
@yozora/tokenizer-heading produce Heading type nodes. See documentation for details.
Install
npm
npm install --save @yozora/tokenizer-heading
yarn
yarn add @yozora/tokenizer-heading
Usage
@yozora/tokenizer-heading has been integrated into @yozora/parser /
@yozora/parser-gfm-ex / @yozora/parser-gfm, so you can use YozoraParser
/ GfmExParser
/
GfmParser
directly.
Basic Usage
@yozora/tokenizer-heading 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 HeadingTokenizer from '@yozora/tokenizer-heading'
const parser = new DefaultParser()
.useFallbackTokenizer(new ParagraphTokenizer())
.useFallbackTokenizer(new TextTokenizer())
.useTokenizer(new HeadingTokenizer())
// parse source markdown content
parser.parse(`
# h1
## h2
### h3
#### h4
##### h5
###### h6
`)
Use within @yozora/parser
import YozoraParser from '@yozora/parser'
const parser = new YozoraParser()
// parse source markdown content
parser.parse(`
# h1
## h2
### h3
#### h4
##### h5
###### h6
`)
Use with @yozora/parser-gfm
import GfmParser from '@yozora/parser-gfm'
const parser = new GfmParser()
// parse source markdown content
parser.parse(`
# h1
## h2
### h3
#### h4
##### h5
###### h6
`)
Use within @yozora/parser-gfm-ex
import GfmExParser from '@yozora/parser-gfm-ex'
const parser = new GfmExParser()
// parse source markdown content
parser.parse(`
# h1
## h2
### h3
#### h4
##### h5
###### h6
`)
Options
| Name | Type | Required | Default |
| :--------: | :------: | :------: | :---------------------------: |
| name
| string
| false
| "@yozora/tokenizer-heading"
|
| 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.