@yozora/tokenizer-list-item
@yozora/tokenizer-list-item produce ListItem type nodes. See documentation for details.
Install
-
npm
npm install --save @yozora/tokenizer-list-item
-
yarn
yarn add @yozora/tokenizer-list-item
Usage
@yozora/tokenizer-list-item 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-list-item 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 ListItemTokenizer from '@yozora/tokenizer-list-item'
const parser = new DefaultYastParser()
.useBlockFallbackTokenizer(new ParagraphTokenizer())
.useInlineFallbackTokenizer(new TextTokenizer())
.useTokenizer(new ListItemTokenizer())
// parse source markdown content
parser.parse(`
- a
- b
- c
- d
- e
- f
- g
---
- [ ] This is a TODO item.
- [-] This is a processing TODO item.
- [x] This is a finished TODO item.
---
1. This is an ordered list item
a. This is an another type of ordered list item
`)
@yozora/parser
Use withinimport YozoraParser from '@yozora/parser'
const parser = new YozoraParser()
// parse source markdown content
parser.parse(`
- a
- b
- c
- d
- e
- f
- g
---
- [ ] This is a TODO item.
- [-] This is a processing TODO item.
- [x] This is a finished TODO item.
---
1. This is an ordered list item
a. This is an another type of ordered list item
`)
@yozora/parser-gfm
Use withimport GfmParser from '@yozora/parser-gfm'
const parser = new GfmParser()
// parse source markdown content
parser.parse(`
- a
- b
- c
- d
- e
- f
- g
---
- [ ] This is a TODO item.
- [-] This is a processing TODO item.
- [x] This is a finished TODO item.
---
1. This is an ordered list item
a. This is an another type of ordered list item
`)
@yozora/parser-gfm-ex
Use withinimport GfmExParser from '@yozora/parser-gfm-ex'
const parser = new GfmExParser()
// parse source markdown content
parser.parse(`
- a
- b
- c
- d
- e
- f
- g
---
- [ ] This is a TODO item.
- [-] This is a processing TODO item.
- [x] This is a finished TODO item.
---
1. This is an ordered list item
a. This is an another type of ordered list item
`)
Options
Name | Type | Required | Default |
---|---|---|---|
name |
string |
false |
"@yozora/tokenizer-list-item" |
priority |
number |
false |
TokenizerPriority.CONTAINING_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.