Skip to content

Commit dac354f

Browse files
committed
Enable Talon syntax highlighting via shiki
Fixes #255 - It is a little hacky as due to an issue in docusaurus we have to use shiki version ~1.22.2, which predates the bundling of talon's textmate theme so the theme has to be included manually from (https://github.com/mrob95/vscode-TalonScript). - biased on https://lachieh.github.io/docusaurus-with-shiki-rehype/docs/intro/
1 parent 1b32612 commit dac354f

File tree

9 files changed

+980
-14
lines changed

9 files changed

+980
-14
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
This is the source repo for the [Talon wiki](https://talon.wiki), a community maintained wiki for [Talon voice](https://talonvoice.com/). For information on how to contribute, see our [Contributing](https://talon.wiki/CONTRIBUTING/) documentation.
2+
3+
4+
5+
Syntax Highlighting for talon files is from [talon.tmLanguage.json](./talon.tmLanguage.json) https://github.com/mrob95/vscode-TalonScript and is licensed under the MIT License.

docs/Customization/talon-files.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The primary way to extend talon is using `.talon` files placed anywherein the `u
1414

1515
An example `.talon` file might look like this:
1616

17-
```````talon
17+
```talon
1818
# Comments start with a # sign, and they must always be on their own line.
1919
#
2020
# This part, the context header, defines under which circumstances this file applies.
@@ -43,7 +43,7 @@ tag(): user.tabs
4343
# This adjusts settings (within this file's context).
4444
settings():
4545
key_wait = 1.5
46-
```````
46+
```
4747

4848
## Context header
4949

docusaurus.config.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { themes as prismThemes } from "prism-react-renderer";
21
import type { Config } from "@docusaurus/types";
32
import type * as Preset from "@docusaurus/preset-classic";
3+
import rehypeShiki, { RehypeShikiOptions } from "@shikijs/rehype";
4+
import {ShikiTransformer} from "shiki";
5+
import talonLanguage from "./talon.tmLanguage.json" ;
6+
import { transformerColorizedBrackets } from '@shikijs/colorized-brackets'
47

5-
const config: Config = {
8+
9+
const config: Config = {
610
title: "Talon Community Wiki",
711
tagline: "Documentation for using Talon Voice",
812
favicon: "img/talon-community-logo.png",
@@ -39,11 +43,30 @@ const config: Config = {
3943
sidebarPath: "./sidebars.ts",
4044
// Remove this to remove the "edit this page" links.
4145
editUrl: "https://github.com/TalonCommunity/Wiki/edit/main/",
46+
beforeDefaultRehypePlugins: [
47+
[
48+
// customRehypeShiki,
49+
rehypeShiki,
50+
{
51+
themes: {
52+
light: "catppuccin-latte",
53+
dark: "catppuccin-macchiato"
54+
},
55+
inline: 'tailing-curly-colon',
56+
transformers: [
57+
transformerColorizedBrackets() as unknown as ShikiTransformer,
58+
],
59+
langs: ["python", /* other languages */talonLanguage],
60+
} satisfies RehypeShikiOptions,
61+
],
62+
],
63+
4264
},
4365
theme: {
4466
customCss: "./src/css/custom.css",
4567
},
4668
blog: false,
69+
4770
} satisfies Preset.Options,
4871
],
4972
],
@@ -171,11 +194,6 @@ const config: Config = {
171194
],
172195
copyright: `Copyright © ${new Date().getFullYear()} Talon Community`,
173196
},
174-
prism: {
175-
theme: prismThemes.github,
176-
darkTheme: prismThemes.dracula,
177-
additionalLanguages: ["talon"],
178-
},
179197
colorMode: {
180198
respectPrefersColorScheme: true,
181199
},

0 commit comments

Comments
 (0)