Skip to content
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

rehype-pretty-code doesn't preserve the language if it's unknown #136

Closed
jackyzha0 opened this issue Dec 19, 2023 · 3 comments · Fixed by #139
Closed

rehype-pretty-code doesn't preserve the language if it's unknown #136

jackyzha0 opened this issue Dec 19, 2023 · 3 comments · Fixed by #139
Labels
bug Something isn't working

Comments

@jackyzha0
Copy link

Before upgrading to 0.12.1, Quartz used to have code that looks like this:

visit(tree, "code", (node: Code) => {
  if (node.lang === "mermaid") {
    node.data = {
      hProperties: {
        className: ["mermaid"],
      },
    }
  }
})

This would run in a remark plugin before rehype-pretty-code does. I'm guessing that the old implementation would respect the hProperties on the code block but shikiji straight up just replaces it? In any case, this would also be solved if data-language contained the code block language even if it isn't a recognized language (right now, it seems to default to the empty string if it's not detected)

@jackyzha0
Copy link
Author

Related issue within Quartz: jackyzha0/quartz#638

@jackyzha0 jackyzha0 changed the title rehype-pretty-code no longer passes unknown languages through to the data-language rehype-pretty-code doesn't preserve the language if it's unknown Dec 19, 2023
@jackyzha0
Copy link
Author

jackyzha0 commented Dec 19, 2023

#69 (comment) the crux of this issue seems to be the same one that this other comment mentions

is there a way to keep node.properties after it gets transformed into a div?

@atomiks
Copy link
Collaborator

atomiks commented Dec 19, 2023

@jackyzha0 I think the issue was the transformation of properties wasn't respecting the existing properties, can you check if the linked PR ^ fixes it?

@atomiks atomiks added the bug Something isn't working label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants