Skip to content

Broken Typst highlight #1012

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

Open
3 of 5 tasks
l0uisgrange opened this issue May 10, 2025 · 2 comments
Open
3 of 5 tasks

Broken Typst highlight #1012

l0uisgrange opened this issue May 10, 2025 · 2 comments

Comments

@l0uisgrange
Copy link

l0uisgrange commented May 10, 2025

Validations

Describe the bug

Hi!

I just noticed that in Typst language, if you put something like this:

#import "@preview/zap:0.2.0"

#zap.canvas({
    import zap: *

    isource("i1", (0,0), (5,0))
})

Inside Shiki, the inside of the {} is totally broken (the text is full black). It looks like this with the GitHub light theme:

Image

But if I remove the zap before the canvas, everything works perfectly:

Image

Here's the code I used :

const highlighter = await createHighlighter({
    themes: ['github-light-default', 'github-dark-default'],
    langs: ['typst']
});
code = highlighter.codeToHtml(content.toString(), {
    theme: isDarkMode ? 'github-dark-default' : 'github-light-default',
    lang: language
});

You can go to the minimal reproduction below and npm run dev, then check http://localhost:5173/zap/docs to see the problem. The Code component is under src/components/Code.svelte.

Reproduction

https://github.com/l0uisgrange/shiki-minimal-example

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@l0uisgrange
Copy link
Author

I have tested it on Safari, Chrome and Edge, they all have this issue, so it does not seem to be linked to #1005.

I also noticed an issue with dashes. The expected look is this:

#import "@preview/zap:0.2.0"

#canvas({
    import zap: *
    set-style(stroke: 1pt)
    // Your amazing circuit
})

but the look given by Shiki is this:

Image

@Myriad-Dreamin
Copy link

I suggest update to this one. The current typst grammar used by shiki was made by the typst owner when they made their thesis (2022).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants