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
Codeblock does not style properly #9347
Comments
@xiaohai-huang i want to work on this issue can you please elaborate it and assign me |
@Chetax I am unable to assign people. What else do you need to know about the issue? Have you tried to visit the page https://xiaohai.wiki/docs/Web/JavaScript/this#default-binding? |
Hmm, weird I can also see this behavior on this code block for example ```js title='"use strict" in function definition (contents)' {2,8}
function foo() {
"use strict";
console.log(this.a);
}
var a = 2; // is declared in the global scope
foo(); // Uncaught TypeError: Cannot read properties of undefined (reading 'a')
``` https://xiaohai.wiki/docs/Web/JavaScript/this#default-binding I wonder if it's not related to a React hydration issue, as we had some in v2 (cf this other issue #9208) Maybe it will work better once you upgrade to Docusaurus v3 (I'll publish a blog post very soon to help you do so). @Chetax it doesn't look like a good first issue. Also we don't assign issues here: you either know how to handle it and submit a draft PR, or you don't and find another issue to work on. |
@slorber ok i will find another issue to work on. |
@slorber I have upgraded to "3.0.0-beta.0". The issue still exists. 3.0.0-beta.0 version of the page Here is how I upgrade my site. PR |
The issue occurs because I created a custom component called My |
Hmmm, then this does not seem like a Docusaurus bug. You can post further details below, but I would encourage you to debug yourself, and if you have questions, you can start a discussion thread instead. |
Solve this issue by following the instruction from prism-react-renderer | Custom Language Support import { Highlight, Prism } from "prism-react-renderer";
(typeof global !== "undefined" ? global : window).Prism = Prism
await import("prismjs/components/prism-applescript")
/** or **/
require("prismjs/components/prism-applescript") |
Great Now in v3 those errors are logged to the console so it's easier to identify them. That's outside the scope of Docusaurus to fix them since it's not our code, but glad you fixed it 👍 |
@xiaohai-huang by chance can you give us feedback on how easy it was to upgrade to v3? Do we need to document or clarify anything that you struggled with? |
Things that I struggled with
Maybe you should add "Make sure to use remark-math >= 5 and rehype-katex >= 6 for Docusaurus v3 (using MDX v2)." to the upgrade guide as well. |
Thanks for the feedback!
True. Actually Prettier does not "officially" support MDX v2 and might cause troubles sometimes. Related: Unfortunately there's nothing we can do apart opting out with prettier ignore or disabling prettier entirely. Note: I think it works fine most of the time and we shouldn't need to stop recommending the usage of prettier. Also, it also had shortcomings with MDX v1.
We have documented it in https://docusaurus.io/blog/preparing-your-site-for-docusaurus-v3#try-docusaurus-v3-today TS 5+ and MDX React 2.3+ should work fine.
Also documented: use https://docusaurus.io/blog/preparing-your-site-for-docusaurus-v3#typescript-base-config
Any message to share? that would help 😅 After an upgrade,
True, this is something I'll fix Error messages are not always easy to understand but we referenced some of them in the blog post here:
Thanks, will do 👍 |
Regarding the Math/katex upgrades, I think not possible now because this blog post is about preparing your v2 site, and is not full v3 upgrade guide. Apparently the newer math/katex versions are not compatible with mdx v1/Docusaurus v2 so this does not qualify as "preparatory work". We can only upgrade those plugins when doing the v3 upgrade, not ahead of time. BTW @Josh-Cena you wrote this section about using newer version: Have you been able to do that in practice? Because I couldn't make it work 😅 https://stackblitz.com/edit/github-xqy2c4?file=docusaurus.config.js,docs%2Fintro.md,package.json |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
VID_20230928_144046.mp4
Bad Format Codeblock
The codeblock does not style properly.
Normal Codeblock
After refreshing the page, all codeblocks become normal.
Reproducible demo
Steps to reproduce
Expected behavior
Actual behavior
Your environment
Self-service
The text was updated successfully, but these errors were encountered: