forked from getzola/zola
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is copied from getzola#913 Co-Authored-By: Uwe Arzt <[email protected]>
- Loading branch information
1 parent
8b414ac
commit 7472f1d
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
docs/content/documentation/content/css-syntax-highlighting.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
+++ | ||
title = "CSS Syntax Highlighting" | ||
weight = 80 | ||
+++ | ||
|
||
If you use a highlighting scheme like | ||
|
||
```toml | ||
highlight_theme = "base16-ocean-dark" | ||
``` | ||
|
||
for a code block like | ||
|
||
````md | ||
```rs | ||
let highlight = true; | ||
``` | ||
```` | ||
|
||
you get the colors directly encoded in the html file | ||
|
||
```html | ||
<pre style="background-color:#2b303b;"> | ||
<code> | ||
<span style="color:#b48ead;">let</span> | ||
<span style="color:#c0c5ce;"> highlight = </span> | ||
<span style="color:#d08770;">true</span> | ||
<span style="color:#c0c5ce;">; | ||
</span> | ||
</code> | ||
</pre> | ||
``` | ||
|
||
this is nice, because if everything is inside one file, you get fast | ||
page loadings. But if you would like to have the user choose a theme from a | ||
list, or different color schemes for dark/light color schemes, ou need a | ||
different solution. | ||
|
||
If you use the special color scheme | ||
|
||
```toml | ||
highlight_theme = "css" | ||
``` | ||
|
||
you get CSS class definitions | ||
|
||
```html | ||
<pre class="code"> | ||
<code class="code"> | ||
<span class="source rust"> | ||
<span class="storage type rust">let</span> highlight | ||
<span class="keyword operator assignment rust">=</span> | ||
<span class="constant language rust">true</span> | ||
<span class="punctuation terminator rust">;</span> | ||
</span> | ||
</code> | ||
</pre> | ||
``` | ||
|
||
now you can generate and use CSS either manually or with Zola | ||
|
||
```toml | ||
highlighting_themes_css = [ | ||
{ theme = "base16-ocean-dark", filename = "syntax-theme-dark.css" }, | ||
{ theme = "base16-ocean-light", filename = "syntax-theme-light.css" }, | ||
] | ||
``` | ||
|
||
```css | ||
@import url("syntax-theme-dark.css") (prefers-color-scheme: dark); | ||
@import url("syntax-theme-light.css") (prefers-color-scheme: light); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters