[EuiCodeBlock] Replace highlight.js with prism.js via refractor#4638
[EuiCodeBlock] Replace highlight.js with prism.js via refractor#4638thompsongl merged 32 commits intoelastic:masterfrom
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. |
| exports[`EuiCodeBlockImpl block renders a pre block tag 1`] = ` | ||
| <div | ||
| class="euiCodeBlock euiCodeBlock--fontSmall euiCodeBlock--paddingLarge testClass1 testClass2" | ||
| class="euiCodeBlock euiCodeBlock--fontSmall euiCodeBlock--paddingLarge prismjs language-none testClass1 testClass2" |
There was a problem hiding this comment.
Did the old version used to also default to no highlighting?
|
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/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4638/ |
chandlerprall
left a comment
There was a problem hiding this comment.
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/ |
chandlerprall
left a comment
There was a problem hiding this comment.
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.jswithprism.jsviarefractorfor 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-prismjsplugin for EuiMarkdown* (replaces 3rd-partyremark-highlight.js)Breaking change(s):
No syntax language auto-detection(Not actually breaking)highlight.jstextdoes not existshis not an alias forbashjswill not highlightjsx-specific tokensTo do:
react-window)Checklist
- [ ] Checked in mobile- [ ] Checked Code Sandbox works for the any docs examples