-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiCodeBlock] Replace highlight.js with prism.js via refractor #4638
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Certainly possible. Will need to update our |
Certainly possible. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Yes. We can save up to an additional ~300k (~1.8MB total) by not including the full language set. Instead, we'd load import refractor from 'refractor/core';
import jsx from 'refractor/lang/jsx';
import sql from 'refractor/lang/sql';
refractor.register(jsx);
refractor.register(sql); Obviously we'd need to decide on EUI's core set of supported languages. |
Yes, but probably an either/or with "reducing initial language load". |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Opening this up for review. Looking for early feedback on:
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
I'm fine with this so long as we document this very well. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic conversion! I was happy to see how straight forward the markdown changes are, in particular. Couple notes on windows line breaks but everything else LGTM!
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM! Pulled & tested locally
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
* replace highlight.js with prism.js via refractor * merge fix: file renamed * group lines * update tests * i18n block * remove regex lookbehind not supported in safari * CL * js -> jsx * token color parity * update line grouping method * use jsx language in docs * reduce newlines * docs * docs * headings * Update src-docs/src/views/code/code_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * playground updates * os newlines Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
…a single one when using the Copy button This change was first introduced in 7aeb30f ([EuiCodeBlock] Replace highlight.js with prism.js via refractor (elastic#4638)) but doesn't seem to be a business or product decision. We decided to remove it to make the copied content match what's displayed on screen.
…a single one when using the Copy button This change was first introduced in 7aeb30f ([EuiCodeBlock] Replace highlight.js with prism.js via refractor (elastic#4638)) but doesn't seem to be a business or product decision. We decided to remove it to make the copied content match what's displayed on screen.
…a single one when using the Copy button This change was first introduced in 7aeb30f ([EuiCodeBlock] Replace highlight.js with prism.js via refractor (elastic#4638)) but doesn't seem to be a business or product decision. We decided to remove it to make the copied content match what's displayed on screen.
…character (#6794) * fix(EuiCodeBlock): fix code block copy button not including the last character if it's a question mark * chore: add changelog file * fix(EuiCodeBlock): Remove reducing two or more consecutive empty lines to a single one when using the Copy button This change was first introduced in 7aeb30f ([EuiCodeBlock] Replace highlight.js with prism.js via refractor (#4638)) but doesn't seem to be a business or product decision. We decided to remove it to make the copied content match what's displayed on screen. * Revert "fix(EuiCodeBlock): Remove reducing two or more consecutive empty lines to a single one when using the Copy button" This reverts commit 8a90215c81432514493b1bb29ecd314d6792a05d. * docs: add clarification comment why \n\n replace is needed * Update regression test * changelog --------- Co-authored-by: Constance Chen <constance.chen.3@gmail.com> Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
Summary
Closes #3947 (and replaces #4400)
Replaces
highlight.js
withprism.js
viarefractor
for code syntax highlighting.This is currently a 1:1 replacement with no additional features (e.g., code block virtualization).
Current bundle size reduction: ~1.5MB (~1.1MB minified) 🎉
Affects:
New:
remark-prismjs
plugin for EuiMarkdown* (replaces 3rd-partyremark-highlight.js
)Breaking change(s):
No syntax language auto-detection(Not actually breaking)highlight.js
text
does not existsh
is not an alias forbash
js
will not highlightjsx
-specific tokensTo do:
react-window
)Checklist
- [ ] Checked in mobile- [ ] Checked Code Sandbox works for the any docs examples