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

Package detail

@yozora/tokenizer-break

yozorajs6.4kMIT2.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-break

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-break

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-break

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-break

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 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-break

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 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-break

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)

Performance Improvements

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

2.0.0 (2022-01-15)

Performance Improvements

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

Features

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

Performance Improvements

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

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

Performance Improvements

  • 🎨 refactor parse-inline hooks (455cfbd)
  • 🎨 refactor removePosition (87a974f)
  • 🔖 publish v2.0.0-alpha.2 (da59d85)

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

Bug Fixes

  • 🐛 fix incorrect export names (b2d1fa7)

Performance Improvements

  • 🎨 refactor inline tokenizers (b3ff235)
  • 🔖 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 inline tokenizers (85e2d65)
  • 🔖 publish v2.0.0-alpha.0 (0171501)
  • 🎨 rename parser hooks (ef6cbc5)
  • 🎨 set print width to 100 (657a621)

1.3.0 (2021-10-09)

Features

  • 💥 move func parameter nodePoints to api.getNodePoints() (6bbfd4e)
  • 💥 move func parameter nodePoints to api.getNodePoints() (10e5033)

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

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

Performance Improvements

1.0.0 (2021-07-20)

Performance Improvements

1.0.0-beta.0 (2021-07-08)

Performance Improvements

  • 🔖 publish v1.0.0-beta.0 (bb66320)

1.0.0-1.0.0-beta.0.0 (2021-07-08)

Performance Improvements

  • 🔖 publish v1.0.0-1.0.0-beta.0.0 (4051dd2)
  • ⚡️ remove unnecessary codes (cebe92a)
  • 📝 update READMEs (9d9f940)

1.0.0-alpha.29 (2021-07-08)

Performance Improvements

  • expose new utility func 'createTester' and 'createTesters' (a4e9613)
  • 📝 fix invalid link references (f7b97b3)
  • 🔖 publish v1.0.0-alpha.29 (f2291db)
  • 🎨 use path alias in tests (29cca94)

1.0.0-alpha.28 (2021-06-30)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.28 (f18d90a)

1.0.0-alpha.27 (2021-06-28)

Performance Improvements

  • 🎨 update base abstract tokenizer (cca9dd6)
  • 🔖 publish v1.0.0-alpha.27 (8efea07)
  • ⬆️ upgrade dev dependencies (d126ff4)

1.0.0-alpha.26 (2021-06-25)

Performance Improvements

1.0.0-alpha.25 (2021-06-17)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.25 (5e17f71)
  • ⚰️ remove delimiterGroup as we are no longer need it (e9de208)
  • 🎨 rewrite due to the algorithm changed (7216611)

1.0.0-alpha.24 (2021-06-10)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.24 (6169f8e)

1.0.0-alpha.23 (2021-06-08)

Performance Improvements

  • Move repository from github.com/guanghechen to github.com/yozorajs (c1fd32c)
  • 🔖 publish v1.0.0-alpha.23 (131a216)
  • 📝 update READMEs (6420941)

1.0.0-alpha.22 (2021-05-20)

Performance Improvements

  • 🎨 lint codes (0d2d798)
  • 🔖 publish v1.0.0-alpha.22 (a07a41d)
  • 🔧 rename the main branch to 'main' instead of 'master' (c915653)

1.0.0-alpha.21 (2021-05-12)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.21 (e6655a2)

1.0.0-alpha.20 (2021-04-20)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.20 (3f3831f)

1.0.0-alpha.19 (2021-04-19)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.19 (50b55f9)
  • 📝 update READMEs (907af97)

1.0.0-alpha.18 (2021-04-18)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.18 (219b28b)

1.0.0-alpha.17 (2021-04-15)

Performance Improvements

1.0.0-alpha.16 (2021-04-12)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.16 (9da34dd)
  • ✅ simplify test codes (60d072c)

1.0.0-alpha.15 (2021-04-11)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.15 (988d25f)

1.0.0-alpha.14 (2021-04-11)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.14 (3fcfffa)
  • 🎨 rename isContainerBlock to isContainingBlock & use enum TokenizerPriority instead of magic numbers to present tokenizer proirity (940c50b)
  • ✅ update tests (3c9f64f)
  • ✅ update tests (a24d148)

1.0.0-alpha.13 (2021-04-10)

Performance Improvements

  • 🎨 add api for match-inline and parse-inline phase (150231a)
  • 🔖 publish v1.0.0-alpha.13 (949455c)

1.0.0-alpha.12 (2021-03-27)

Features

  • 💥 redesign interfaces & refactor tokenizer codes with types from @yozora/ast (af3603d)

Performance Improvements

  • 🎨 add static uniqueName into tokenizers (f6e2c77)
  • 🎨 make '_tokenizer' optional in the result of tokenizers on match phase (b1ea8de)
  • 🔖 publish v1.0.0-alpha.12 (897f131)
  • 🎨 use AST types from @yozora/ast instead of @yozora/core-tokenizer (fc55ceb)
  • 🎨 use types defined in @yozora/ast & use tokenizerName as unique id of token (d51f022)

1.0.0-alpha.11 (2021-03-20)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.11 (df10f73)

1.0.0-alpha.10 (2021-03-20)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.10 (dbd0114)

1.0.0-alpha.9 (2021-03-20)

Performance Improvements

  • 📝 fix invalid badge urls (4d78b23)
  • 🔖 publish v1.0.0-alpha.9 (1b41b56)

1.0.0-alpha.8 (2021-03-13)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.8 (3cb3080)
  • 📝 update badges (418e221)
  • 🔧 update configs & lint codes (3e9ded3)
  • 🔧 update package.json (cba99c5)
  • 📝 update READMEs (188b30b)

1.0.0-alpha.7 (2021-03-06)

Performance Improvements

  • 🎨 format codes (1fbd596)
  • 🔧 add directory in repository field (8daefc9)
  • 📝 update badges (967819b)
  • 🔖 publish v1.0.0-alpha.7 (115ce36)
  • 🔧 update scripts field (72841c5)
  • 🔧 use @guanghechen/rollup-config instead of @barusu/rollup-config (6228c33)
  • 🔨 use top level rollup.config.js (818c59b)

1.0.0-alpha.6 (2021-02-25)

Performance Improvements

  • 🎨 format codes through 'yarn sort-imports' (a932fec)
  • 🎨 format codes with prettier (04582c8)
  • 🔖 publish v1.0.0-alpha.6 (e4f20f7)
  • 🚚 rename @yozora/parser-core to @yozora/core-parser (e94956f)
  • ⬆️ upgrade @barusu/* to v0.0.47 & upgrade rollup to v2.39.1 (173b431)
  • 🔧 upgrade barusu to v0.0.46 (7c360a4)
  • 🔧 upgrade eslint & update eslint configs & lint codes (4227453)

1.0.0-alpha.5 (2021-02-23)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.5 (fa285da)

1.0.0-alpha.4 (2021-02-23)

Performance Improvements

  • :art: merge @yozora/tokenizercore-inline and @yozora/tokenizercore-block into @yozora/tokenizercore (7583266)
  • 🎨 move property recongnizedTypes from TokenizerParseBlockHook and TokenizerParseInlineHook into the Tokenizer (d3ec789)
  • 🔖 publish v1.0.0-alpha.4 (1cfd290)
  • 🎨 rename tokenizer hooks (9f0679f)
  • 🔧 update jest config (2142751)
  • 📝 update README (57663fd)
  • 📝 update READMEs (c421f5c)

1.0.0-alpha.3 (2021-02-18)

Performance Improvements

  • 🔖 publish v1.0.0-alpha.3 (ba9b6dd)
  • 🚚 rename @yozora/tokenizer-line-break to @yozora/tokenizer-break (6442a76)