@yozora/tokenizer-ecma-import
npm i @yozora/tokenizer-ecma-import

@yozora/tokenizer-ecma-import

A customizable markdown parser for resolving markdown-like syntax strings into AST.

by yozorajs

2.0.2-alpha.0 (see all)License:MITTypeScript:Built-In
npm i @yozora/tokenizer-ecma-import
Readme

@yozora/tokenizer-ecma-import


@yozora/tokenizer-ecma-import parse ECMAScript import statement. It should be noted that only single-line import statements are supported. in addition * as and type import are not support. For example, the following import statements are supported:

import '@yozora/parser'
import Parser from '@yozora/parser'
import Parser, { YozoraParserProps } from '@yozora/parser'
import { YozoraParserProps } from '@yozora/parser'
import { YozoraParser, YozoraParser as Parser } from '@yozora/parser'

And here is the not supported case:

import * as Parser '@yozora/parser'
import {
  Parser
} from '@yozora/parser'

See documentation for details.

Install

  • npm

    npm install --save @yozora/tokenizer-ecma-import
    
  • yarn

    yarn add @yozora/tokenizer-ecma-import
    

Usage

@yozora/tokenizer-ecma-import has been integrated into @yozora/parser, so you can use YozoraParser directly.

Basic Usage

@yozora/tokenizer-ecma-import 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 EcmaImportTokenizer from '@yozora/tokenizer-ecma-import'

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

// parse source markdown content
parser.parse(`
import { Parser } from '@yozora/parser'
import { Button } from '@material-ui/core'
import Markdown from '@yozora/react-markdown'
`)

Use within @yozora/parser

import YozoraParser from '@yozora/parser'

const parser = new YozoraParser()

// parse source markdown content
parser.parse(`
import { Parser } from '@yozora/parser'
import { Button } from '@material-ui/core'
import Markdown from '@yozora/react-markdown'
`)

Use with @yozora/parser-gfm

import GfmParser from '@yozora/parser-gfm'
import EcmaImportTokenizer from '@yozora/tokenizer-ecma-import'

const parser = new GfmParser()
parser.useTokenizer(new EcmaImportTokenizer())

// parse source markdown content
parser.parse(`
import { Parser } from '@yozora/parser'
import { Button } from '@material-ui/core'
import Markdown from '@yozora/react-markdown'
`)

Use within @yozora/parser-gfm-ex

import GfmExParser from '@yozora/parser-gfm-ex'
import EcmaImportTokenizer from '@yozora/tokenizer-ecma-import'

const parser = new GfmExParser()
parser.useTokenizer(new EcmaImportTokenizer())

// parse source markdown content
parser.parse(`
import { Parser } from '@yozora/parser'
import { Button } from '@material-ui/core'
import Markdown from '@yozora/react-markdown'
`)

Options

NameTypeRequiredDefault
namestringfalse"@yozora/tokenizer-ecma-import"
prioritynumberfalseTokenizerPriority.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 the match-block stage, a high-priority tokenizer can interrupt the matching process of a low-priority tokenizer.

Downloads/wk

12

GitHub Stars

129

LAST COMMIT

1mo ago

MAINTAINERS

1

CONTRIBUTORS

2

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
2.0.2-alpha.0
latest
1mo ago
No alternatives found
No tutorials found
Add a tutorial