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

update dependencies to add ansi highlighting support #1810

Merged
merged 4 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/moody-maps-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'nextra-theme-blog': minor
'nextra-theme-docs': minor
'nextra': minor
---

support ANSI highlighting
28 changes: 28 additions & 0 deletions docs/pages/docs/guide/syntax-highlighting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,34 @@ Renders:
console.log('hello, world')
```

### ANSI Highlighting

You can highlight ANSI escape codes:

````md filename="Markdown"
```ansi
 ✓ src/index.test.ts (1)
 Test Files  1 passed (1)
 Tests  1 passed (1)
 Start at  23:32:41
 Duration  11ms
 PASS  Waiting for file changes...
press h to show help, press q to quit
```
````

Renders:

```ansi
 ✓ src/index.test.ts (1)
 Test Files  1 passed (1)
 Tests  1 passed (1)
 Start at  23:32:41
 Duration  11ms
 PASS  Waiting for file changes...
press h to show help, press q to quit
```

## Supported Languages

Check [this list](https://github.com/shikijs/shiki/blob/main/docs/languages.md) for all supported languages.
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"remark-reading-time": "^2.0.1",
"shiki": "^0.14.0",
"shiki": "^0.14.2",
"slash": "^3.0.0",
"title": "^3.5.3",
"unist-util-remove": "^3.1.1",
Expand Down
18 changes: 17 additions & 1 deletion packages/nextra/src/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@
"type": "css",
"colors": {
"editor.foreground": "#000001",
"editor.background": "#000002"
"editor.background": "#000002",
"terminal.ansiBlack": "#A00000",
"terminal.ansiRed": "#A00001",
"terminal.ansiGreen": "#A00002",
"terminal.ansiYellow": "#A00003",
"terminal.ansiBlue": "#A00004",
"terminal.ansiMagenta": "#A00005",
"terminal.ansiCyan": "#A00006",
"terminal.ansiWhite": "#A00007",
"terminal.ansiBrightBlack": "#A00008",
"terminal.ansiBrightRed": "#A00009",
"terminal.ansiBrightGreen": "#A00010",
"terminal.ansiBrightYellow": "#A00011",
"terminal.ansiBrightBlue": "#A00012",
"terminal.ansiBrightMagenta": "#A00013",
"terminal.ansiBrightCyan": "#A00014",
"terminal.ansiBrightWhite": "#A00015"
},
"tokenColors": [
{
Expand Down
68 changes: 68 additions & 0 deletions packages/nextra/styles/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,40 @@
--shiki-token-string-expression: var(--shiki-token-string);
--shiki-token-punctuation: oklch(24.78% 0 0);
--shiki-token-link: var(--shiki-token-string);

/* from github-light */
--shiki-color-ansi-black: #24292e;
--shiki-color-ansi-black-dim: #24292e80;
--shiki-color-ansi-red: #d73a49;
--shiki-color-ansi-red-dim: #d73a4980;
--shiki-color-ansi-green: #28a745;
--shiki-color-ansi-green-dim: #28a74580;
--shiki-color-ansi-yellow: #dbab09;
--shiki-color-ansi-yellow-dim: #dbab0980;
--shiki-color-ansi-blue: #0366d6;
--shiki-color-ansi-blue-dim: #0366d680;
--shiki-color-ansi-magenta: #5a32a3;
--shiki-color-ansi-magenta-dim: #5a32a380;
--shiki-color-ansi-cyan: #1b7c83;
--shiki-color-ansi-cyan-dim: #1b7c8380;
--shiki-color-ansi-white: #6a737d;
--shiki-color-ansi-white-dim: #6a737d80;
--shiki-color-ansi-bright-black: #959da5;
--shiki-color-ansi-bright-black-dim: #959da580;
--shiki-color-ansi-bright-red: #cb2431;
--shiki-color-ansi-bright-red-dim: #cb243180;
--shiki-color-ansi-bright-green: #22863a;
--shiki-color-ansi-bright-green-dim: #22863a80;
--shiki-color-ansi-bright-yellow: #b08800;
--shiki-color-ansi-bright-yellow-dim: #b0880080;
--shiki-color-ansi-bright-blue: #005cc5;
--shiki-color-ansi-bright-blue-dim: #005cc580;
--shiki-color-ansi-bright-magenta: #5a32a3;
--shiki-color-ansi-bright-magenta-dim: #5a32a380;
--shiki-color-ansi-bright-cyan: #3192aa;
--shiki-color-ansi-bright-cyan-dim: #3192aa80;
--shiki-color-ansi-bright-white: #d1d5da;
--shiki-color-ansi-bright-white-dim: #d1d5da80;
}

.dark {
Expand All @@ -23,4 +57,38 @@
--shiki-token-string-expression: oklch(69.28% 0.179 143.2);
--shiki-token-punctuation: oklch(79.21% 0 0);
--shiki-token-link: var(--shiki-token-string);

/* from github-dark */
--shiki-color-ansi-black: #586069;
--shiki-color-ansi-black-dim: #58606980;
--shiki-color-ansi-red: #ea4a5a;
--shiki-color-ansi-red-dim: #ea4a5a80;
--shiki-color-ansi-green: #34d058;
--shiki-color-ansi-green-dim: #34d05880;
--shiki-color-ansi-yellow: #ffea7f;
--shiki-color-ansi-yellow-dim: #ffea7f80;
--shiki-color-ansi-blue: #2188ff;
--shiki-color-ansi-blue-dim: #2188ff80;
--shiki-color-ansi-magenta: #b392f0;
--shiki-color-ansi-magenta-dim: #b392f080;
--shiki-color-ansi-cyan: #39c5cf;
--shiki-color-ansi-cyan-dim: #39c5cf80;
--shiki-color-ansi-white: #d1d5da;
--shiki-color-ansi-white-dim: #d1d5da80;
--shiki-color-ansi-bright-black: #959da5;
--shiki-color-ansi-bright-black-dim: #959da580;
--shiki-color-ansi-bright-red: #f97583;
--shiki-color-ansi-bright-red-dim: #f9758380;
--shiki-color-ansi-bright-green: #85e89d;
--shiki-color-ansi-bright-green-dim: #85e89d80;
--shiki-color-ansi-bright-yellow: #ffea7f;
--shiki-color-ansi-bright-yellow-dim: #ffea7f80;
--shiki-color-ansi-bright-blue: #79b8ff;
--shiki-color-ansi-bright-blue-dim: #79b8ff80;
--shiki-color-ansi-bright-magenta: #b392f0;
--shiki-color-ansi-bright-magenta-dim: #b392f080;
--shiki-color-ansi-bright-cyan: #56d4dd;
--shiki-color-ansi-bright-cyan-dim: #56d4dd80;
--shiki-color-ansi-bright-white: #fafbfc;
--shiki-color-ansi-bright-white-dim: #fafbfc80;
}
Loading