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

Fix Docsy to work with latest highlight styles #312

Merged
merged 4 commits into from
Jul 22, 2020
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
13 changes: 4 additions & 9 deletions assets/scss/_code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
// Highlighted code.
.highlight {
@extend .card;
margin: 2rem 0;
padding: 1rem;
background-color: $gray-100;

pre, div {
background-color: inherit !important;
}

padding: 0;

pre {
margin: 0;
padding: 0;
padding: 1rem;
}
}

Expand Down
5 changes: 5 additions & 0 deletions userguide/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ weight = 1
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
[markup.highlight]
# See a complete list of available styles at https://xyproto.github.io/splash/docs/all.html
style = "tango"
# Uncomment if you want your chosen highlight style used for code blocks without a specified language
# guessSyntax = "true"

# Everything below this are Site Params

Expand Down
24 changes: 24 additions & 0 deletions userguide/content/en/docs/Adding content/lookandfeel.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@ When you use `.-bg-<color>`, the text colors will be adjusted to get proper cont

<div class="-text-blue pt-3 display-4">Text: Blue</div>

## Code highlighting

With Hugo version 0.60 and higher, you can choose from a range of code block highlight and colour styles using [Chroma](https://github.com/alecthomas/chroma) that are applied to your fenced code blocks by default. If you copied a recent `config.toml` your site uses Tango (like this site), otherwise the Hugo default is Monokai. You can switch to any of the [available Chroma styles](https://xyproto.github.io/splash/docs/all.html) (including our Docsy default Tango) using your `config.toml`:

```toml
[markup]
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
[markup.highlight]
# See a complete list of available styles at https://xyproto.github.io/splash/docs/all.html
style = "tango"
```

By default code highlighting styles are not applied to code blocks without a specified language, instead you get Docsy's default style of grey with black text. If you would like the code highlighting style to apply to all code blocks, even without a language, uncomment or add the following line under `[markup.highlight]` in your `config.toml`.

```toml
# Uncomment if you want your chosen highlight style used for code blocks without a specified language
guessSyntax = "true"
```

You can find out more about code highlighting in Hugo with Chroma in [Syntax Highlighting](https://gohugo.io/content-management/syntax-highlighting/).


## Customizing templates

### Add code to head or before body end
Expand Down