Skip to content

Get langs path from outside unpkg cdn #365

@titonova

Description

@titonova

Currently, to register a new language you can use this step:

 shiki.getHighlighter({
        theme: 'nord',
        langs:[
                {
                    id: 'blade',
                    scopeName: 'text.html.php.blade',
                    path: 'languages/blade.tmLanguage.json',  //<------------------------------------
                    aliases: ['blade']
                }
        ]
      })

However, shiki forces the path to relative to the unpkg v0.11.1 cdn. What if I wanted to get a language grammar from my local file, or another cdn, or a lower version ?

 shiki.getHighlighter({
        theme: 'nord',
        langs:[
                {
                    id: 'blade',
                    scopeName: 'text.html.php.blade',
                    path: '/js/dist/languages/blade.tmLanguage.json',  //<------------------------------------ this goes to `[unpk](https://unpkg.com/[email protected]//js/shiki/languages/blade.tmLanguage.json` rather than my local file
                    aliases: ['blade']
                }
        ]
      })

EDIT: After digging through the code, i found that I could use this:

shiki.setCDN('https://unpkg.com/browse/[email protected]/')
shiki.getHighlighter({
        theme: 'nord',
        langs:[
      ........

However, I get this error:

Uncaught (in promise) CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0

Btw, if you're wondering why I'm trying to manually set the CDN, it's because Shiki versions above 0.10.1 have a bug when using the CDN. So, I am using 0.10.1, but the blade grammar is only available on unpkg shiki version 0.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions