forked from Sync/hugo-theme-stack
21bd04ec89
* fix(codeblock): pass through the options of chroma Pass through the options of chroma highlighting processing for whom may use some options in codeblock. This commit fix problem with the following scenarios: ```python {linenos=true} print("Hello World") ``` Signed-off-by: cubercsl <2014cais01@gmail.com> * fix(codeblock): margin of no highlight codeblock This commit fix the wrong margin value of the codeblock which can not highlight. The margin is now use the value of ".article-content pre" Signed-off-by: cubercsl <2014cais01@gmail.com> Signed-off-by: cubercsl <2014cais01@gmail.com>
21 lines
763 B
HTML
21 lines
763 B
HTML
{{- $class := .Attributes.class | default "" -}}
|
|
{{- $lang := .Attributes.lang | default .Type -}}
|
|
<div class="codeblock">
|
|
<header>
|
|
<span class="codeblock-lang">{{ $lang }}</span>
|
|
<button
|
|
class="codeblock-copy"
|
|
data-id="codeblock-id-{{ .Ordinal }}"
|
|
data-copied-text="{{ T `article.codeblock.copied` }}"
|
|
>
|
|
{{ T `article.codeblock.copy` }}
|
|
</button>
|
|
</header>
|
|
<code id="codeblock-id-{{ .Ordinal }}" style="display:none;">{{- .Inner -}}</code>
|
|
{{- if transform.CanHighlight $lang -}}
|
|
<div class="{{ $class }}">{{- highlight .Inner $lang .Options -}}</div>
|
|
{{- else -}}
|
|
<pre><code class="{{ $class }}">{{- .Inner -}}</code></pre>
|
|
{{- end -}}
|
|
</div>
|