@yozora/tokenizer-table
@yozora/tokenizer-table produce [Table][node-type-table] / [TableRow][node-type-table-cell] / [TableCell][node-type-table-cell] type nodes. See documentation for details.
Install
-
npm
npm install --save @yozora/tokenizer-table
-
yarn
yarn add @yozora/tokenizer-table
Usage
@yozora/tokenizer-table has been integrated into @yozora/parser / @yozora/parser-gfm-ex,
so you can use YozoraParser
/ GfmExParser
directly.
Basic Usage
@yozora/tokenizer-table 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 TableTokenizer from '@yozora/tokenizer-table'
const parser = new DefaultParser()
.useFallbackTokenizer(new ParagraphTokenizer())
.useFallbackTokenizer(new TextTokenizer())
.useTokenizer(new TableTokenizer())
// parse source markdown content
parser.parse(`
| foo | bar |
| --- | --- |
| baz | bim |
`)
@yozora/parser
Use withinimport YozoraParser from '@yozora/parser'
const parser = new YozoraParser()
// parse source markdown content
parser.parse(`
| foo | bar |
| --- | --- |
| baz | bim |
`)
@yozora/parser-gfm
Use withimport GfmParser from '@yozora/parser-gfm'
import TableTokenizer from '@yozora/tokenizer-table'
const parser = new GfmParser()
parser.useTokenizer(new TableTokenizer())
// parse source markdown content
parser.parse(`
| foo | bar |
| --- | --- |
| baz | bim |
`)
@yozora/parser-gfm-ex
Use withinimport GfmExParser from '@yozora/parser-gfm-ex'
const parser = new GfmExParser()
// parse source markdown content
parser.parse(`
| foo | bar |
| --- | --- |
| baz | bim |
`)
Options
Name | Type | Required | Default |
---|---|---|---|
name |
string |
false |
"@yozora/tokenizer-table" |
priority |
number |
false |
TokenizerPriority.INTERRUPTABLE_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.