-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(theme-classic): syntax-highlighting for inline code #8717
base: main
Are you sure you want to change the base?
Conversation
Hi @zepatrik! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
const { | ||
prism: {defaultLanguage}, | ||
} = useThemeConfig(); | ||
const language = languageProp ?? defaultLanguage ?? 'text'; |
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.
This is also the worst-case fallback in the CodeBlock
.
packages/docusaurus-theme-classic/src/theme/CodeInline/index.tsx
Outdated
Show resolved
Hide resolved
I am not quite sure why the CI fails on this branch 😅 It does not really seem related, but 🤷 |
@zepatrik docusaurus/packages/docusaurus/src/client/serverEntry.tsx Lines 45 to 63 in fabf053
Try removing all the |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Thanks for the pointer @Josh-Cena, now it built locally at least. |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Thanks, that looks like a nice feature to add. Will review it soon, would like to try running this PR with my new visual diffing test project here, to see if there is any unexpected visual side-effect on our site: https://github.com/slorber/docusaurus-visual-tests Something cool we could add later: a provider + docs/blog frontMatter to allow defining an inline code block language for a whole page or a whole children tree. If a blog post is 100% about TS that's cool to enable inline syntax highlighting everywhere by simply using markdown inline code blocks. |
Agreed, that would be very cool! Also fairly easy to implement, but the interface might not be straight-forward. But yeah, a topic for another day. Btw, I saw that you are aiming for a v3 release already, is there any timeline for that? Will v2 be discontinued like v1 or maintained in parallel? |
As soon as MDX 2 + React 18 are ready, working on it but it's not so easy.
v3 will not be a total rewrite like v2 was so it should be easier to upgrade |
Hey @slorber did you already try this PR with your visual diff tool? Do you need me to do something else to get this merged? |
@zepatrik until Docusaurus v3 is out this PR is not a top priority for me, unfortunately. I'll review it when I can Rebasing could trigger the Argos CI visual diff but I'm not sure the setup works great currently |
Pre-flight checklist
Motivation
Currently, there is no way to highlight the syntax in inline code.
Test Plan
I have added a section to the docs that uses the feature. I am not sure how to properly test this going further.
Test links
from https://deploy-preview-8717--docusaurus-2.netlify.app/docs/markdown-features/code-blocks/#syntax-highlighting
Deploy preview: https://deploy-preview-8717--docusaurus-2.netlify.app/
Related issues/PRs
I did not really find any.