Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@yozora/tokenizer-ecma-import

yozorajs6.3kMIT2.3.12TypeScript support: included

null

readme

Yozora
logo.png


See Yozora document (or https://yozorajs.github.io) for more details.

https://user-images.githubusercontent.com/42513619/129205123-6a1983c4-6a86-4c80-83d6-02bdbf70edbf.mp4


中文文档

🎉 Why named "yozora" ?

Yozora is the Roman sound of Japanese 「よぞら」, taken from the lyrics in『花鳥風月』 by the band 世界の終わり.

This project is a monorepo that aims to implement a highly extensible, pluggable Markdown parser. Based on the idea of middlewares, the core algorithm @yozora/core-parser will schedule tokenizers (such as @yozora/tokenizer-autolink) to complete the parsing tasks. More accurately, yozora is an algorithm to parse Markdown or its extended syntax contents into an abstract syntax tree (AST).

✨ Features

  • 🔖 Fully support all the rules mentioned in the GFM specification, and has passed almost all test cases created based on the examples in the specification (except the one https://github.github.com/gfm/#example-653, as there is no plan to support native HTML tags in the React Renderer, for the Yozora AST, so I'm a little lazy to do the tag filtering. If you need it, you can do the filtering by yourself).

    See @yozora/parser-gfm or @yozora/parser-gfm-ex for further information.

  • 🚀 Robust.

    • All codes are written in Typescript, with the guarantee of strictly static type checking.

    • Eslint and Prettier to constrain coding styles to avoid error-prone problems such as hack syntax and shadow variables.

    • Tested with Jest, and passed a large number of test cases.

  • 💚 Tidy: No third-party dependencies.

  • ⚡️ Efficient.

    • The parsing complexity is the length of source contents multiplied by the number of tokenizers, which has reached the lower bound of theoretical complexity.

    • The parser API supports streaming read-in (using generators /iterators for input), and supports parsing while read-in (Only block-level data is supported yet).

    • Carefully handle the array creation / concat operations. To reused the array as much as possible during the entire matching phase, only use the array index to delineate the matching range. And a lot of strategies applied to reduce duplicated matching / parsing operations.

  • 🩹 Compatibility, the parsed syntax tree is compatible with the one defined in Mdast.

    Even if some data types are not compatible in the future, it is easy to traverse the AST for adaptation and modification through the API provided in @yozora/ast-util.

  • 🎨 Extendibility, Yozora comes with a plug-in system, which allowed Yozora to schedule the tokenizers through an internal algorithms to complete the parsing tasks.

    • It's easy to create and integrate custom tokenizers.
    • All tokenizers can be mounted or unmounted freely.

      Some tokenizers of the data types that not mentioned in GFM have been implemented in this repository, such as @yozora/tokenizer-admonition, @yozora/tokenizer-footnote, etc. All of them are built into @yozora/parser in default, you can uninstall them at will, if you don't like it.

Usage

  • @yozora/parser: (Recommended) A Markdown parser with rich built-in tokenizers.

    import YozoraParser from '@yozora/parser'
    
    const parser = new YozoraParser()
    parser.parse('source content')
  • @yozora/parser-gfm: A Markdown parser that supports GFM specification. Built-in tokenizers that supports all grammars mentioned in GFM specification (excluding the extended grammar mentioned in the specification, such as table).

    import GfmParser from '@yozora/parser-gfm'
    
    const parser = new GfmParser()
    parser.parse('github flavor markdown contents')
  • @yozora/parser-gfm-ex: A Markdown parser that supports GFM specification. Built-in tokenizers that supports all grammars mentioned in GFM specification (including the extended grammar mentioned in the specification, such as table).

    import GfmExParser from '@yozora/parser-gfm-ex'
    
    const parser = new GfmExParser()
    parser.parse('github flavor markdown contents (with gfm extensions enabled)')
  • Content AST into markup content

    import { DefaultMarkupWeaver } from '@yozora/markup-weaver'
    
    const weaver = new DefaultMarkupWeaver()
    weaver.weave({
      "type": "root",
      "children": [
        {
          "type": "paragraph",
          "children": [
            {
              "type": "text",
              "value": "emphasis: "
            },
            {
              "type": "strong",
              "children": [
                {
                  "type": "text",
                  "value": "foo \""
                },
                {
                  "type": "emphasis",
                  "children": [
                    {
                      "type": "text",
                      "value": "bar"
                    }
                  ]
                },
                {
                  "type": "text",
                  "value": "\" foo"
                }
              ]
            }
          ]
        }
      ]
    })
    // => emphasis: **foo "*bar*" foo**

Overview

💡 FAQ

💬 Contact

📄 License

Yozora is MIT licensed.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.12 (2025-02-26)

  • :bookmark: release: publish v2.3.10 (a36b4dd)
  • :bookmark: release: publish v2.3.11 (dcc0a95)
  • :bookmark: release: publish v2.3.8 (c4ddb8b)
  • :bookmark: release: publish v2.3.9 (d125df1)
  • chore: fix nx dependencies (d11d405)

2.3.11 (2025-01-13)

Note: Version bump only for package @yozora/tokenizer-ecma-import

2.3.10 (2025-01-09)

  • chore: fix nx dependencies (d11d405)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.9 (2024-12-05)

Note: Version bump only for package @yozora/tokenizer-ecma-import

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.8 (2024-12-03)

  • :bookmark: release: publish v2.3.7 (ba79410)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.7 (2024-11-06)

Note: Version bump only for package @yozora/tokenizer-ecma-import

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.6 (2024-10-23)

Note: Version bump only for package @yozora/tokenizer-ecma-import

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.5 (2024-10-06)

  • :bookmark: release: publish v2.3.3 (be6d159)
  • :bookmark: release: publish v2.3.4 (ac66f62)
  • :wrench: chore: fix build error (06f839d)
  • :wrench: chore: fix lint (224e248)
  • :wrench: chore: fix nx config (139b132)
  • :wrench: chore: fix nx config (b8c4d73)
  • :wrench: chore: fix nx config (38c2325)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.4 (2024-09-29)

Note: Version bump only for package @yozora/tokenizer-ecma-import

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.3 (2024-09-20)

  • :wrench: chore: fix build error (06f839d)
  • :wrench: chore: fix lint (224e248)
  • :wrench: chore: fix nx config (b8c4d73)
  • :wrench: chore: fix nx config (38c2325)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.2 (2024-06-17)

Note: Version bump only for package @yozora/tokenizer-ecma-import

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.1 (2024-01-30)

Performance Improvements

  • 🔧 use nx to simplify running commands on the monorepo (#25) (377a126)

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

2.3.0 (2023-09-18)

Performance Improvements

  • :fire: remove 'tsconfig.json's in sub packages (1e6a8b3)

2.2.0 (2023-08-21)

Performance Improvements

  • ⬆️ upgrade devDependencies (bc46ce2)

2.1.5 (2023-05-13)

Performance Improvements

  • 🔧 don't sourcemaps into tarball (fc37aa8)
  • 📝 update CHANGELOGs (c51b283)

2.1.4 (2023-04-02)

Performance Improvements

  • 🔧 don't pack src/ folder into tarball (c9fac38)
  • 🔖 publish v2.1.4 (aa464ed)

2.1.3 (2023-03-23)

Performance Improvements

2.1.2 (2023-03-11)

Performance Improvements

2.1.1 (2023-03-10)

Performance Improvements

2.0.6 (2023-03-05)

Performance Improvements

2.0.5 (2023-01-09)

Performance Improvements

2.0.5-alpha.0 (2023-01-05)

Performance Improvements

  • 🔧 fix test configuration (f50b2d7)
  • 🔖 publish v2.0.5-alpha.0 (8bf941f)
  • 🔧 update package entries (2c94f27)
  • ⬆️ upgrade devDependencies (13059a9)

2.0.4 (2022-11-02)

Performance Improvements

2.0.3 (2022-10-11)

Performance Improvements

2.0.2 (2022-09-24)

Performance Improvements

2.0.2-alpha.0 (2022-05-22)

Performance Improvements

  • 🔖 publish v2.0.2-alpha.0 (430eaab)

2.0.1 (2022-05-21)

Bug Fixes

  • 🐛 fix the trailing semicolon cannot be recognized (e0184e4)

Performance Improvements

  • ✅ refactor test utils & rename createTester to createTokenizerTester (7f2ce75)
  • 🔖 publish v2.0.1 (3aea330)

2.0.0 (2022-01-15)

Performance Improvements

  • 💥 [breaking] rename 'NodePoint' and 'NodePosition' (76692a2)
  • 🔖 publish v2.0.0 (65e99d1)

2.0.0-alpha.3 (2022-01-12)

Features

  • 💥 [breaking] remove 'I' prefix for AST node types (cad4b0b)
  • 💥 [breaking] remove 'IYastNode' prefix for AST types (35c8fd2)

Performance Improvements

  • 🔖 publish v2.0.0-alpha.3 (9f274fc)

2.0.0-alpha.2 (2022-01-09)

Performance Improvements

  • 🎨 refactor removePosition (87a974f)
  • 🔖 publish v2.0.0-alpha.2 (da59d85)

2.0.0-alpha.1 (2022-01-08)

Features

  • :breaking: refactor parse-block hooks (117104d)

Performance Improvements

  • 🔖 publish v2.0.0-alpha.1 (86202e1)
  • 🎨 rename IHookContext to IThis (04d5470)
  • 📝 update READMEs (320afeb)

2.0.0-alpha.0 (2022-01-03)

Features

  • 💥 [breaking] rename types with 'I' prefix (d37d862)

Performance Improvements

  • 💥 refactor block tokenizers (50ea4da)
  • 🔖 publish v2.0.0-alpha.0 (0171501)
  • 🎨 rename parser hooks (ef6cbc5)
  • 🎨 set print width to 100 (657a621)

1.3.0 (2021-10-09)

Performance Improvements

1.2.2 (2021-09-06)

Performance Improvements

1.2.1 (2021-09-04)

Performance Improvements

1.2.0 (2021-08-22)

Performance Improvements

1.2.0-alpha.1 (2021-08-16)

Performance Improvements

  • 🔖 publish v1.2.0-alpha.1 (ce3c173)

1.2.0-alpha.0 (2021-08-15)

Performance Improvements

  • 🔖 publish v1.2.0-alpha.0 (bd8ef45)

1.1.0 (2021-08-12)

Performance Improvements

  • 🔖 publish v1.1.0 (a8c7cff)
  • 📝 update related references (e2c8c7e)

1.1.0-alpha.2 (2021-08-07)

Performance Improvements

  • 🔖 publish v1.1.0-alpha.2 (d88b8ec)

1.1.0-alpha.1 (2021-08-01)

Performance Improvements

  • 🚚 move EcmaImport types from @yozora/tokenizer-ecma-import to @yozora/ast (cf14076)
  • 🔖 publish v1.1.0-alpha.1 (0d6aa91)
  • 📝 update READMEs (738d626)

1.1.0-alpha.0 (2021-07-31)

Features

  • ✨ implement new tokenizer '@yozora/tokenizer-ecma-import' (7e4a1b1)

Performance Improvements

  • 🔖 publish v1.1.0-alpha.0 (082653e)