Skip to content

Expose Tokenizer interface to accept custom tokenizer other than Prism at @lexical/code - #3243

Merged
fantactuka merged 1 commit into
meta:mainfrom
saint1991:feature/custom-tokenizer
Oct 24, 2022
Merged

fantactuka merged 1 commit into
meta:mainfrom
saint1991:feature/custom-tokenizer

Conversation

@saint1991

Copy link
Copy Markdown
Contributor

Prism has powerful functionality to handle various languages including custom language,
but some other tools like ANTLR have their own grammar definition and parser generator.

This PR exposes the Tokenizer interface at registerCodeHighlighting in @lexical/code plugin to handle such a case.

@vercel

vercel Bot commented Oct 23, 2022 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
lexical ✅ Ready (Inspect) Visit Preview Oct 23, 2022 at 5:21AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview Oct 23, 2022 at 5:21AM (UTC)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 23, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep compatibility, add tokenizer as an optional argument.
If it is not specified, PrismTokenizer will be used like before (at line 693).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tokenizer implementation using Prism that is the same as the original implementation and this will be used as default.

@fantactuka

fantactuka commented Oct 24, 2022 •

Copy link
Copy Markdown
Contributor

Much needed PR!
0.6 release could introduce a breaking change where tokenizer is required and prism one is not included into the bundle

@danestves

Copy link
Copy Markdown

This will be perfect, I want to use other code highlight than Prism!

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — f79d5503 Deployed Oct 23, 2022 by vercel[bot]
Preview – lexical — f79d5503 Deployed Oct 23, 2022 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants