Welcome to mirror list, hosted at ThFree Co, Russian Federation.

render-codeblock.html « _markup « _default « layouts - github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 21c5100260246b188e49ac9015579fd28f98ea7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{{- $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 -}}</div>
    {{- else -}}
    <pre><code class="{{ $class }}">{{- .Inner -}}</code></pre>
    {{- end -}}
</div>