highlight: don't switch to block view if hl_inline=true #618

This commit is contained in:
Sören Weber 2023-08-14 10:36:48 +02:00
parent cbfe2076cf
commit f51f843ca6
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
2 changed files with 11 additions and 2 deletions

View file

@ -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.<br><br>The default value can be set in your `config.toml` and overwritten via frontmatter. [See below](#configuration). |
| **options** | _&lt;empty&gt;_ | 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. |
| _**&lt;option&gt;**_ | _&lt;empty&gt;_ | Any of [Hugo's supported options](https://gohugo.io/functions/highlight/#options). |

View file

@ -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]*<div\\s+class=\")" "${1}wrap-code " $content 1 }}
{{- end }}
{{- if $title }}
{{- if and $title (not $hl_inline) }}
{{ partial "shortcodes/tab.html" (dict
"page" $page
"title" $title