From f51f843ca61c4293ef4c9f891a87ac602ad099b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Mon, 14 Aug 2023 10:36:48 +0200 Subject: [PATCH] highlight: don't switch to block view if hl_inline=true #618 --- exampleSite/content/shortcodes/highlight.en.md | 2 +- layouts/partials/shortcodes/highlight.html | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/exampleSite/content/shortcodes/highlight.en.md b/exampleSite/content/shortcodes/highlight.en.md index 29c099a302..f1d41f7dad 100644 --- a/exampleSite/content/shortcodes/highlight.en.md +++ b/exampleSite/content/shortcodes/highlight.en.md @@ -80,7 +80,7 @@ print("Hello World!") | Name | Default | Notes | |-----------------------|------------------|-------------| | **type** | _<empty>_ | The language of the code to highlight. Choose from one of the [supported languages](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages). Case-insensitive. | -| **title** | _<empty>_ | **Extension**. Arbitrary title for code. This displays the code like a [single tab]({{% relref "shortcodes/tab" %}}). | +| **title** | _<empty>_ | **Extension**. Arbitrary title for code. This displays the code like a [single tab]({{% relref "shortcodes/tab" %}}) if `hl_inline=false` (which is Hugos default). | | **wrap** | see notes | **Extension**. When `true` the content may wrap on long lines otherwise it will be scrollable.

The default value can be set in your `config.toml` and overwritten via frontmatter. [See below](#configuration). | | **options** | _<empty>_ | An optional, comma-separated list of zero or more [Hugo supported options](https://gohugo.io/functions/highlight/#options) as well as extension parameter from this table. | | _**<option>**_ | _<empty>_ | Any of [Hugo's supported options](https://gohugo.io/functions/highlight/#options). | diff --git a/layouts/partials/shortcodes/highlight.html b/layouts/partials/shortcodes/highlight.html index 4b32d25967..a6f558bc8d 100644 --- a/layouts/partials/shortcodes/highlight.html +++ b/layouts/partials/shortcodes/highlight.html @@ -47,6 +47,15 @@ {{- end }} {{- $options = $otherOptions }} {{- $attributes = $attributes | merge $otherAttributes }} +{{- $hl_inline := false }} +{{- if and (isset $page.Params "markup") (isset $page.Params.markup "highlight") (isset $page.Params.markup.highlight "hl_inline") }} + {{- $hl_inline = $page.Params.markup.highlight.hl_inline }} +{{- end }} +{{- range $k, $v := $options }} + {{- if eq $k "hl_inline" }} + {{- $hl_inline = $v }} + {{- end }} +{{- end }} {{- $params := slice }} {{- range $k, $v := $options }} {{- $params = $params | append (printf "%s=%s" $k $v) }} @@ -75,7 +84,7 @@ {{- if $wrap }} {{- $content = replaceRE "^([\\s\\n\\r]*