@yozora/tokenizer-link-reference
TypeScript icon, indicating that this package has built-in type declarations

2.3.7 • Public • Published

@yozora/tokenizer-link-reference produce LinkReference type nodes. See documentation for details.

Install

  • npm

    npm install --save @yozora/tokenizer-link-reference
  • yarn

    yarn add @yozora/tokenizer-link-reference

Usage

@yozora/tokenizer-link-reference 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-link-reference 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 LinkReferenceTokenizer from '@yozora/tokenizer-link-reference'

const parser = new DefaultParser()
  .useFallbackTokenizer(new ParagraphTokenizer())
  .useFallbackTokenizer(new TextTokenizer())
  .useTokenizer(new LinkReferenceTokenizer())

// parse source markdown content
parser.parse(`
[foo][bar]

[bar]: /url "title"
`)

Use within @yozora/parser

import YozoraParser from '@yozora/parser'

const parser = new YozoraParser()

// parse source markdown content
parser.parse(`
[foo][bar]

[bar]: /url "title"
`)
import GfmParser from '@yozora/parser-gfm'

const parser = new GfmParser()

// parse source markdown content
parser.parse(`
[foo][bar]

[bar]: /url "title"
`)
import GfmExParser from '@yozora/parser-gfm-ex'

const parser = new GfmExParser()

// parse source markdown content
parser.parse(`
[foo][bar]

[bar]: /url "title"
`)

Options

Name Type Required Default
name string false "@yozora/tokenizer-link-reference"
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 the match-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.

Related

Dependents (4)

Package Sidebar

Install

npm i @yozora/tokenizer-link-reference

Weekly Downloads

782

Version

2.3.7

License

MIT

Unpacked Size

76.7 kB

Total Files

7

Last publish

Collaborators

  • lemonclown