-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Fix: fetchTheme
theme 'include' directory joining for absolute paths
#173
Fix: fetchTheme
theme 'include' directory joining for absolute paths
#173
Conversation
Hi there, I have run into the same issue this PR resolves -- specifically, loading themes directly from VSCode installations does not work because of the relative path issues outlined here. Is there any chance this PR could be merged? |
✅ Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
👋🏻 sorry for the super late review, trying to get a sense of why this is marked as draft? I think supporting relative paths is a good call (think I hit this also) and your implementation is thoroughly tested and looks good to me |
👋 Hey @orta - I've forgotten exactly why I marked it as draft, I think! 🙈 Reading my notes, I think I felt I'd perhaps not manually tested thoroughly enough - not enough in the browser perhaps, just in the VSCode extension context I was hacking around in? I've removed the draft flag so it's marked ready for review. Getting late here, but I'll take a look in at those test failures tomorrow, though at a glance I'm not sure they're related to this PR? 🕵️ |
Yep, I bet a rebase will fix it with #335 |
If themeOne included themeTwo using an 'include' property, fetchTheme would previously take ONLY the dirname component of themeOne (i.e. the last directory in the path), and combine it with the 'included' value. E.g. if ~/foo/bar/baz.json included `./bing.json`, fetchTheme would try to get the include by using bar/bing,json, which wouldn't work. This amends it to use the entire path of the original, _except_ for whatever comes after the last dir separator. So now if e.g. ~/foo/bar/baz.json included `./bing.json`, fetchTheme will get the include by using `/foo/bar/bing.json`
d523998
to
42ef15f
Compare
Nearly there - rebased, but looks like |
@orta Rebased, and updated that test - looks like we're good to go! Let me know if you need anything else 🙏 |
👍🏻 thanks! |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [shiki](https://togithub.com/octref/shiki/tree/main/packages/shiki) ([source](https://togithub.com/octref/shiki)) | [`^0.11.1` -> `^0.14.4`](https://renovatebot.com/diffs/npm/shiki/0.11.1/0.14.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/0.14.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/0.14.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/0.11.1/0.14.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/0.11.1/0.14.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>octref/shiki (shiki)</summary> ### [`v0.14.4`](https://togithub.com/octref/shiki/blob/HEAD/CHANGELOG.md#0144--2023-08-31) [Compare Source](https://togithub.com/octref/shiki/compare/v0.14.3...v0.14.4) ##### 🚀 Features & Fixes - feat: add ziglang - fix: inconsistent git core.ignorecase causes marko.sample added/removed - feat: add mojo lang - feat: add `mdc` grammar ##### 🙌 Contributions - feat: add additional sample code | [#​511](https://togithub.com/shikijs/shiki/pull/511) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) - fix: Compiler errors in Node | [#​504](https://togithub.com/shikijs/shiki/pull/504) | [@​Gerrit0](https://togithub.com/Gerrit0) - feat: add splunk grammar | [#​505](https://togithub.com/shikijs/shiki/pull/505) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) - Add bun support | [#​493](https://togithub.com/shikijs/shiki/pull/493) | [@​aabccd021](https://togithub.com/aabccd021) - feat: add shellsession grammar | [#​483](https://togithub.com/shikijs/shiki/pull/483) | [@​mashehu](https://togithub.com/mashehu) ### [`v0.14.3`](https://togithub.com/octref/shiki/blob/HEAD/CHANGELOG.md#0143--2023-06-25) [Compare Source](https://togithub.com/octref/shiki/compare/v0.14.2...v0.14.3) ##### 🚀 Features & Fixes - fix: exclude dark/light modern themes for now - fix: fix unzipping issue with unzipper. fix [#​478](https://togithub.com/octref/shiki/issues/478) ##### 🙌 Contributions - feat: add narrat grammar | [#​489](https://togithub.com/shikijs/shiki/pull/489) | [@​liana-p](https://togithub.com/liana-p) - feat: add glimmer js/ts language | [#​486](https://togithub.com/shikijs/shiki/pull/486) | [@​IgnaceMaes](https://togithub.com/IgnaceMaes) - feat: add `displayName` to `BUNDLED_LANGUAGES` | [#​470](https://togithub.com/shikijs/shiki/pull/470) | [@​lawvs](https://togithub.com/lawvs) - Specify langs in browser based example | [#​477](https://togithub.com/shikijs/shiki/pull/477) | [@​wesbos](https://togithub.com/wesbos) - feat: add hjson | [#​471](https://togithub.com/shikijs/shiki/pull/471) | [@​AkaraChen](https://togithub.com/AkaraChen) - feat: add nextflow grammar | [#​472](https://togithub.com/shikijs/shiki/pull/472) | [@​mashehu](https://togithub.com/mashehu) - feat: add cypher grammar | [#​465](https://togithub.com/shikijs/shiki/pull/465) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) - feat: add vyper grammar | [#​466](https://togithub.com/shikijs/shiki/pull/466) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) - feat: add beancount grammar | [#​468](https://togithub.com/shikijs/shiki/pull/468) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) ### [`v0.14.2`](https://togithub.com/octref/shiki/blob/HEAD/CHANGELOG.md#0142--2023-04-28) [Compare Source](https://togithub.com/octref/shiki/compare/v0.14.1...v0.14.2) ##### 🚀 Features & Fixes - fix: improve changelog generation - fix: remove dlx to avoid playwright version mismatch - feat: generate changelog. fix [#​223](https://togithub.com/octref/shiki/issues/223) ##### 🙌 Contributions - feat: add kusto grammar ([#​431](https://togithub.com/octref/shiki/issues/431)) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) - Add support for the css-variables theme to ansi rendering | [#​435](https://togithub.com/shikijs/shiki/pull/435) | [@​blake-mealey](https://togithub.com/blake-mealey) - feat: add wolfram grammar | [#​464](https://togithub.com/shikijs/shiki/pull/464) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) - feat: add c++ and golang support | [#​459](https://togithub.com/shikijs/shiki/pull/459) | [@​xinconan](https://togithub.com/xinconan) - fix: avoid poisoning global scope | [#​457](https://togithub.com/shikijs/shiki/pull/457) | [@​Ayc0](https://togithub.com/Ayc0) - fix(type): `theme` field autocompletion | [#​449](https://togithub.com/shikijs/shiki/pull/449) | [@​vaakian](https://togithub.com/vaakian) - feat: add reg grammar | [#​455](https://togithub.com/shikijs/shiki/pull/455) | [@​KevinBatdorf](https://togithub.com/KevinBatdorf) - Update Kotlin grammar and add a sample | [#​445](https://togithub.com/shikijs/shiki/pull/445) | [@​alllex](https://togithub.com/alllex) - fix: marko, mdx, vue | [#​452](https://togithub.com/shikijs/shiki/pull/452) | [@​LeoDog896](https://togithub.com/LeoDog896) - feat(gd\*): add gdscript family | [#​451](https://togithub.com/shikijs/shiki/pull/451) | [@​LeoDog896](https://togithub.com/LeoDog896) - fix: add `protobuf` language id alias | [#​446](https://togithub.com/shikijs/shiki/pull/446) | [@​dimitropoulos](https://togithub.com/dimitropoulos) - feat(lang): add alias dockerfile -> docker | [#​444](https://togithub.com/shikijs/shiki/pull/444) | [@​ezracelli](https://togithub.com/ezracelli) - fix: faster parsing time for assets | [#​443](https://togithub.com/shikijs/shiki/pull/443) | [@​banga](https://togithub.com/banga) - docs: update the src of VS Code Oniguruma repo | [#​440](https://togithub.com/shikijs/shiki/pull/440) | [@​donaldxdonald](https://togithub.com/donaldxdonald) - docs: fix grammar of "grammar's" | [#​442](https://togithub.com/shikijs/shiki/pull/442) | [@​comex](https://togithub.com/comex) *** ##### 0.14.1 | 2023-02-09 - 🙌 Scrollable <pre> elements should be focusable. [#​428](https://togithub.com/shikijs/shiki/issues/428). Thanks to contribution from [@​kevinleedrum](https://togithub.com/kevinleedrum). ##### 0.14.0 | 2023-01-29 - 🙌 ANSI support. [#​386](https://togithub.com/shikijs/shiki/issues/386). Thanks to contribution from [@​blake-mealey](https://togithub.com/blake-mealey). ##### 0.13.0 | 2023-01-27 - Improve grammar/theme fetching from marketplace. - 🙌 Support CSON grammar sources. [#​413](https://togithub.com/shikijs/shiki/issues/413). Thanks to contribution from [@​muenzpraeger](https://togithub.com/muenzpraeger) - Add a [Next.js 13 example](https://togithub.com/shikijs/next-shiki). - Add a `bgFillOpacity` option for SVG renderer. [#​276](https://togithub.com/shikijs/shiki/issues/276). *Languages* - Added `console` as an alias for `shell`. [#​389](https://togithub.com/shikijs/shiki/issues/389). - 🙌 Added `jison` and `wgsl` languages. [#​413](https://togithub.com/shikijs/shiki/issues/413). Thanks to contribution from [@​muenzpraeger](https://togithub.com/muenzpraeger) *Themes* - Renamed `material-<themeName>` to `material-theme-<themeName>`. For example, `material-ocean` to `material-theme-ocean`. `material-default` is renamed to `material-theme`. *** ##### 0.10.1 - 🙌: feat: add ZenScript support [#​300](https://togithub.com/shikijs/shiki/pull/300) | **[@​jaredlll08](https://togithub.com/jaredlll08)** - 🙌: feat: add marko language [#​299](https://togithub.com/shikijs/shiki/pull/299) | **[@​manan-gup](https://togithub.com/manan-gup)** - 🙌: fix: split plaintext into lines [#​298](https://togithub.com/shikijs/shiki/pull/298) | **[@​silvenon](https://togithub.com/silvenon)** - 🙌: fix(docs): fixed custom language instructions [#​294](https://togithub.com/shikijs/shiki/pull/294) | **[@​JuanM04](https://togithub.com/JuanM04)** - 🙌: fix: updated astro grammar source [#​293](https://togithub.com/shikijs/shiki/pull/293) | **[@​JuanM04](https://togithub.com/JuanM04)** - 🙌: feat: add rel lang [#​287](https://togithub.com/shikijs/shiki/pull/287) | **[@​robbear](https://togithub.com/robbear)** - 🙌: feat: add rose pine themes [#​282](https://togithub.com/shikijs/shiki/pull/281) | **[@​EmeraldSnorlax](https://togithub.com/EmeraldSnorlax)** - 🙌: feat: add stata lang [#​281](https://togithub.com/shikijs/shiki/pull/281) | **[@​kylebutts](kylebutts)** **Full Changelog**: [v0.10.0...v0.10.1](https://togithub.com/shikijs/shiki/compare/v0.10.0...v0.10.1) *** ##### 0.2.7 | 2020-11-13 - Fix color fallback issues. [#​100](https://togithub.com/shikijs/shiki/issues/100). - 🙌 Add Applescript grammar. [#​99](https://togithub.com/shikijs/shiki/issues/99). Thanks to contribution from [Arturo Galán](https://togithub.com/arturogalan). ##### 0.2.6 | 2020-09-28 - Upgrade to onigasm 2.2.5. - Add Erlang grammar. - 🙌 Add Elixir grammar. [#​95](https://togithub.com/shikijs/shiki/issues/95). Thanks to contribution from [Sebastien Baudray](https://togithub.com/https://github.com/sbaudray). - 🙌 Fix wrong escape sequence in vuepress plugin. [#​93](https://togithub.com/shikijs/shiki/issues/93). Thanks to contribution from [Yu Zhang](https://togithub.com/yzhang-gh). ##### 0.2.5 | 2020-09-17 - Reduce dependency size (shiki-themes is 47M). [#​94](https://togithub.com/shikijs/shiki/issues/94). ##### 0.2.4 | 2020-09-13 - Fix `RangeError: Invalid array length` in `vuepress-plugin-shiki`. - 🙌 Wrap line in `<span class='line'></span>`. [#​76](https://togithub.com/shikijs/shiki/issues/76). Thanks to contribution from [Christoph Werner](https://togithub.com/codepunkt). ##### 0.2.3 | 2020-09-08 - Add `文言` language. [#​88](https://togithub.com/shikijs/shiki/issues/88). - Add `slack-theme-dark-mode` and `slack-theme-ochin` themes. Thanks to contribution from [Christoph Werner](https://togithub.com/codepunkt). [#​78](https://togithub.com/shikijs/shiki/pull/78). ##### 0.2.2 | 2020-08-26 - Fix dark-plus syntax highlighting for uncolored white text. ##### 0.2.1 | 2020-08-24 - Allow custom languages for vuepress. [#​80](https://togithub.com/shikijs/shiki/issues/80). - Fix `php` syntax highlighting. [#​21](https://togithub.com/shikijs/shiki/issues/21). - Add `jinja-html` language, which embeds `jinja` language. [#​24](https://togithub.com/shikijs/shiki/issues/24). - Remove `vue-html` language. Either use `vue` or `html` language. ##### 0.2.0 | 2020-08-24 - Normalize all theme names to kebab-case. - Add GitHub light/dark themes. - Remove less popular themes. - Add `hlsl`, `asm` (x86 Assembly), `m` (Matlab), `sas`, `d`, `dart`, `plsql`, `logo`, , `pas` (Object Pascal/Delphi), `cobol`, `kt` (Kotlin), `scala`, `abap`, `julia`, `scheme`, `prolog`, `ada`, `lisp`, `apex`, `fortran`, `haskell`, `hcl`, `hack`, `awk`, `as` (ActionScript), `tcl`, `ocaml`, `viml`, `puppet`, `jsonnet`, `smalltalk`, `cr` (Crystal), `wat` (WASM), `nix`, `elm`, `purescript` and `svelte` languages. - Add `pug` language and make `jade` an alias of it. - Use GitHub workflow to update grammars periodically. [#​72](https://togithub.com/shikijs/shiki/issues/72). - Use GitHub workflow to update themes periodically. [#​71](https://togithub.com/shikijs/shiki/issues/71). - Use theme foreground color when color of token is `undefined`. [#​27](https://togithub.com/shikijs/shiki/issues/27). - SVG Renderer. [#​2](https://togithub.com/shikijs/shiki/issues/2). - Fix HTML escaping. [#​26](https://togithub.com/octref/shiki/issues/26) and [#​28](https://togithub.com/octref/shiki/pull/28). Thanks to contribution from [@​jackens](https://togithub.com/jackens). - 🙌 Add an option to skip generating the explanation text. [#​52](https://togithub.com/shikijs/shiki/pull/52). Thanks to contribution from [Gerrit Birkeland](https://togithub.com/Gerrit0). - 🙌 Improve performance by avoiding some unnecessary string copies. [#​51](https://togithub.com/shikijs/shiki/pull/51). Thanks to contribution from [Gerrit Birkeland](https://togithub.com/Gerrit0). - 🙌 Allow loading custom `tmLanguage`. [#​10](https://togithub.com/octref/shiki/issues/10) and [#​49](https://togithub.com/octref/shiki/pull/49). Thanks to contribution from [Orta Therox](https://togithub.com/orta) and [@​pngwn](https://togithub.com/pngwn). - 🙌 Update Java grammar. [#​36](https://togithub.com/octref/shiki/issues/36) and [#​37](https://togithub.com/octref/shiki/issues/37). Thanks to contribution from [@​0xflotus](https://togithub.com/0xflotus). ##### 0.1.7 | 2020-04-28 - Update to latest Dark+/Light+ theme from VS Code. ##### 0.1.6 | 2019-09-19 - Add `toml` language from https://github.com/bungcip/better-toml. [#​20](https://togithub.com/octref/shiki/issues/20). ##### 0.1.5 | 2019-09-09 - Begin to keep a changelog. [#​7](https://togithub.com/octref/shiki/issues/7). - Accept `plaintext`, `text` and `txt` as `lang`. Will return `code` as it is. [#​16](https://togithub.com/octref/shiki/issues/16). - Add `jsonc` language. [#​18](https://togithub.com/octref/shiki/issues/18). - Add `csharp` language. [#​14](https://togithub.com/octref/shiki/issues/14). - Add `md` as an alias for `markdown`. - Add `zsh` as an alias for `bash`. - Add `yml` as an alias for `yaml`. - 🙌 Use json5 for parsing theme as JSONC. [#​11](https://togithub.com/octref/shiki/issues/11). Thanks to contribution from [Wes Bos](https://togithub.com/wesbos). ### [`v0.14.1`](https://togithub.com/octref/shiki/blob/HEAD/CHANGELOG.md#0141--2023-02-09) [Compare Source](https://togithub.com/octref/shiki/compare/v0.14.0...v0.14.1) - 🙌 Scrollable <pre> elements should be focusable. [#​428](https://togithub.com/shikijs/shiki/issues/428). Thanks to contribution from [@​kevinleedrum](https://togithub.com/kevinleedrum). ### [`v0.14.0`](https://togithub.com/octref/shiki/blob/HEAD/CHANGELOG.md#0140--2023-01-29) [Compare Source](https://togithub.com/octref/shiki/compare/v0.13.0...v0.14.0) - 🙌 ANSI support. [#​386](https://togithub.com/shikijs/shiki/issues/386). Thanks to contribution from [@​blake-mealey](https://togithub.com/blake-mealey). ### [`v0.13.0`](https://togithub.com/octref/shiki/blob/HEAD/CHANGELOG.md#0130--2023-01-27) [Compare Source](https://togithub.com/octref/shiki/compare/3009d740b25ee2d74ca4ac6ac0e02b06bf567019...v0.13.0) - Improve grammar/theme fetching from marketplace. - 🙌 Support CSON grammar sources. [#​413](https://togithub.com/shikijs/shiki/issues/413). Thanks to contribution from [@​muenzpraeger](https://togithub.com/muenzpraeger) - Add a [Next.js 13 example](https://togithub.com/shikijs/next-shiki). - Add a `bgFillOpacity` option for SVG renderer. [#​276](https://togithub.com/shikijs/shiki/issues/276). *Languages* - Added `console` as an alias for `shell`. [#​389](https://togithub.com/shikijs/shiki/issues/389). - 🙌 Added `jison` and `wgsl` languages. [#​413](https://togithub.com/shikijs/shiki/issues/413). Thanks to contribution from [@​muenzpraeger](https://togithub.com/muenzpraeger) *Themes* - Renamed `material-<themeName>` to `material-theme-<themeName>`. For example, `material-ocean` to `material-theme-ocean`. `material-default` is renamed to `material-theme`. *** ### [`v0.12.1`](https://togithub.com/octref/shiki/compare/v0.12.0...3009d740b25ee2d74ca4ac6ac0e02b06bf567019) [Compare Source](https://togithub.com/octref/shiki/compare/v0.12.0...3009d740b25ee2d74ca4ac6ac0e02b06bf567019) ### [`v0.12.0`](https://togithub.com/shikijs/shiki/releases/tag/v0.12.0) [Compare Source](https://togithub.com/octref/shiki/compare/0b4eec41aab694bab82327aa9740af90054699fb...v0.12.0) <!-- Release notes generated using configuration in .github/release.yml at v0.12.0 --> #### Key Changes Updates to the core libraries used in Shiki, and a *huge* set of docs improvements. - feat: dependency updates incl. textmate by [@​muenzpraeger](https://togithub.com/muenzpraeger) in [https://github.com/shikijs/shiki/pull/377](https://togithub.com/shikijs/shiki/pull/377) - feat: upgrade to vscode-textmate-v7. fix [#​343](https://togithub.com/octref/shiki/issues/343) by [@​octref](https://togithub.com/octref) in [https://github.com/shikijs/shiki/pull/361](https://togithub.com/shikijs/shiki/pull/361) - feat: resolve embedded languages automatically by [@​muenzpraeger](https://togithub.com/muenzpraeger) in [https://github.com/shikijs/shiki/pull/379](https://togithub.com/shikijs/shiki/pull/379) #### What's Changed - Fix: `fetchTheme` theme 'include' directory joining for absolute paths by [@​Oblongmana](https://togithub.com/Oblongmana) in [https://github.com/shikijs/shiki/pull/173](https://togithub.com/shikijs/shiki/pull/173) - feat: update HCL grammar source by [@​dbanck](https://togithub.com/dbanck) in [https://github.com/shikijs/shiki/pull/340](https://togithub.com/shikijs/shiki/pull/340) - Add several alias of languages by [@​dannypsnl](https://togithub.com/dannypsnl) in [https://github.com/shikijs/shiki/pull/344](https://togithub.com/shikijs/shiki/pull/344) - feat: add proto grammar by [@​ruanspies](https://togithub.com/ruanspies) in [https://github.com/shikijs/shiki/pull/352](https://togithub.com/shikijs/shiki/pull/352) - fix: add 'cs' alias for csharp and 'fs' alias for fsharp by [@​mysticmind](https://togithub.com/mysticmind) in [https://github.com/shikijs/shiki/pull/353](https://togithub.com/shikijs/shiki/pull/353) - add imba as a shiki syntax by [@​haikyuu](https://togithub.com/haikyuu) in [https://github.com/shikijs/shiki/pull/363](https://togithub.com/shikijs/shiki/pull/363) - feat(lang): Add V support + robot: update grammars by [@​wennerryle](https://togithub.com/wennerryle) in [https://github.com/shikijs/shiki/pull/374](https://togithub.com/shikijs/shiki/pull/374) - feat: update/add language definitions by [@​muenzpraeger](https://togithub.com/muenzpraeger) in [https://github.com/shikijs/shiki/pull/378](https://togithub.com/shikijs/shiki/pull/378) - feat: add documentation / optimize WASM loading by [@​muenzpraeger](https://togithub.com/muenzpraeger) in [https://github.com/shikijs/shiki/pull/384](https://togithub.com/shikijs/shiki/pull/384) #### New Contributors - [@​Oblongmana](https://togithub.com/Oblongmana) made their first contribution in [https://github.com/shikijs/shiki/pull/173](https://togithub.com/shikijs/shiki/pull/173) - [@​dbanck](https://togithub.com/dbanck) made their first contribution in [https://github.com/shikijs/shiki/pull/340](https://togithub.com/shikijs/shiki/pull/340) - [@​dannypsnl](https://togithub.com/dannypsnl) made their first contribution in [https://github.com/shikijs/shiki/pull/344](https://togithub.com/shikijs/shiki/pull/344) - [@​ruanspies](https://togithub.com/ruanspies) made their first contribution in [https://github.com/shikijs/shiki/pull/352](https://togithub.com/shikijs/shiki/pull/352) - [@​haikyuu](https://togithub.com/haikyuu) made their first contribution in [https://github.com/shikijs/shiki/pull/363](https://togithub.com/shikijs/shiki/pull/363) - [@​wennerryle](https://togithub.com/wennerryle) made their first contribution in [https://github.com/shikijs/shiki/pull/374](https://togithub.com/shikijs/shiki/pull/374) - [@​muenzpraeger](https://togithub.com/muenzpraeger) made their first contribution in [https://github.com/shikijs/shiki/pull/377](https://togithub.com/shikijs/shiki/pull/377) **Full Changelog**: shikijs/shiki@v0.11.0...v0.12.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/levaintech/contented). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi42OC4xIiwidXBkYXRlZEluVmVyIjoiMzYuNjguMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Combo bug report/pull request here - please review carefully when you can, I definitely may have missed things, and I've only examined this fix in the context of using it in a VSCode plugin, and in the node REPL - I haven't tested it in browser etc. I've written some extra tests too. Note though that I'm assuming loadTheme is only meant to work with absolute URLs - see my extra notes at the bottom of this post. Apologies for the wall of text!
I was using
shiki
to load vscode themes using absolute pargs from my local file-system, and if I calledshiki.loadTheme
(i.e.loader.fetchTheme
) with an absolute path for a theme with an'include'
property referring to a second theme, it would try to load the second theme using only the last directory in the path of the first theme, combined with the'include'
property - e.g. if first theme was in/foo/bar/baz/bing.json
and had aninclude
for./buzz.json
, it would think the path for the second file wasbaz/buzz.json
due to the call(join(dirname(themePath), shikiTheme.include)
.So because
fetchTheme
would say the path for theinclude
d theme wasbaz/buzz.json
, this would get to the_resolvePath
function, it would think it was a relative path, and returnpath.resolve(__dirname, '..', filepath);
- giving a very wrong path - in this case, assuming I'm running in/project
, it would give/project/node_modules/shiki/bar/buzz.json
.An example below, where I ran this in the node REPL (having already yarn added
shiki
) to import thelight_plus
theme, whichinclude
s thelight_vs
theme. Should be easy to repro, assuming you are running Windows and have VSCode installed - where I'm trying to load the theme from (this is just an example - I know some of these themes are included in shiki itself!)Relative URLs
As far as I can tell, calling
shiki.loadTheme
doesn't work with with relative URLs? If I try to follow the instructions in themes.md to use a relative parg, it always seems to treat them as relative to the node_modules/shiki directory, regardless of where I run them from - likely due to the_resolvePath
function prepending them with__dirname
. I haven't touched that functionality at all - possibly it might be worth specifying inthemes.md
that custom themes must always be absolute URLs, and maybe adding a guard against it? Probably depends on whether it's meant to handle relative urls or not