@quartz-community/syntax-highlighting 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +28905 -0
- package/dist/index.js.map +1 -0
- package/package.json +117 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial Quartz community plugin template.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Quartz Community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @quartz-community/syntax-highlighting
|
|
2
|
+
|
|
3
|
+
Adds syntax highlighting to code blocks using rehype-pretty-code, with an optional clipboard copy button.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx quartz plugin add github:quartz-community/syntax-highlighting
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```yaml title="quartz.config.yaml"
|
|
14
|
+
plugins:
|
|
15
|
+
- source: github:quartz-community/syntax-highlighting
|
|
16
|
+
enabled: true
|
|
17
|
+
options:
|
|
18
|
+
theme:
|
|
19
|
+
light: github-light
|
|
20
|
+
dark: github-dark
|
|
21
|
+
keepBackground: false
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
For advanced use cases, you can override in TypeScript:
|
|
25
|
+
|
|
26
|
+
```ts title="quartz.ts (override)"
|
|
27
|
+
import * as ExternalPlugin from "./.quartz/plugins";
|
|
28
|
+
|
|
29
|
+
ExternalPlugin.SyntaxHighlighting({
|
|
30
|
+
theme: { light: "github-light", dark: "github-dark" },
|
|
31
|
+
keepBackground: false,
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
| Option | Type | Default | Description |
|
|
38
|
+
| --------------------- | --------------------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| `theme` | `{ light: CodeTheme, dark: CodeTheme }` | `{ light: "github-light", dark: "github-dark" }` | The theme to use for syntax highlighting. |
|
|
40
|
+
| `keepBackground` | `boolean` | `false` | Whether to keep the background color of the code block. |
|
|
41
|
+
| `clipboard` | `boolean` | `true` | Whether to add a clipboard copy button to code blocks. |
|
|
42
|
+
| `tokenClassification` | `boolean` | `true` | Adds `data-token-type` attributes (keyword, string, comment, etc.) to token spans. Enables theme-aware code styling via CSS selectors. |
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
See the [Quartz documentation](https://quartz.jzhao.xyz/plugins/SyntaxHighlighting) for more information.
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Theme as Theme$1 } from 'rehype-pretty-code';
|
|
2
|
+
import { QuartzTransformerPlugin } from '@quartz-community/types';
|
|
3
|
+
export { QuartzTransformerPlugin } from '@quartz-community/types';
|
|
4
|
+
import { ShikiTransformer } from 'shiki';
|
|
5
|
+
|
|
6
|
+
interface Theme extends Record<string, Theme$1> {
|
|
7
|
+
light: Theme$1;
|
|
8
|
+
dark: Theme$1;
|
|
9
|
+
}
|
|
10
|
+
interface SyntaxHighlightingOptions {
|
|
11
|
+
theme?: Theme;
|
|
12
|
+
keepBackground?: boolean;
|
|
13
|
+
clipboard?: boolean;
|
|
14
|
+
tokenClassification?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare const SyntaxHighlighting: QuartzTransformerPlugin<Partial<SyntaxHighlightingOptions>>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Shiki transformer that adds `data-token-type` attributes to token spans
|
|
20
|
+
* based on TextMate scope classification.
|
|
21
|
+
*
|
|
22
|
+
* Automatically enables `includeExplanation: "scopeName"` via the `preprocess`
|
|
23
|
+
* hook so that scope data is available regardless of how the host plugin
|
|
24
|
+
* (e.g. rehype-pretty-code) invokes shiki.
|
|
25
|
+
*
|
|
26
|
+
* This is purely additive — inline styles are preserved as-is. Downstream
|
|
27
|
+
* consumers (e.g. Quartz Themes) can target `span[data-token-type="keyword"]`
|
|
28
|
+
* to override colors with theme-specific values.
|
|
29
|
+
*/
|
|
30
|
+
declare function tokenClassifierTransformer(): ShikiTransformer;
|
|
31
|
+
|
|
32
|
+
export { SyntaxHighlighting, type SyntaxHighlightingOptions, tokenClassifierTransformer };
|