blob: 9e210d23652b8fc7016e13f03f8a5f15e8e6d9ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{{ if .IsNamedParams }}
{{ $.Scratch.Add "c-title" (.Get "title") }}
{{ $.Scratch.Add "c-language" (lower (.Get "lang")) }}
{{ $.Scratch.Add "c-url" (.Get "url") }}
{{ $.Scratch.Add "c-link-text" (.Get "link-text") }}
{{ else }}
{{ if ge (len .Params) 1 }}
{{ $.Scratch.Add "c-title" (.Get 0) }}
{{ end }}
{{ if ge (len .Params) 2 }}
{{ $.Scratch.Add "c-language" (lower (.Get 1)) }}
{{ end }}
{{ if ge (len .Params) 3 }}
{{ $.Scratch.Add "c-url" (.Get 2) }}
{{ end }}
{{ if ge (len .Params) 4 }}
{{ $.Scratch.Add "c-link-text" (.Get 3) }}
{{ end }}
{{ end }}
{{ $trimmedContent := trim .Inner "\n" }}
<figure class="highlight {{ $.Scratch.Get "c-language" }} language-{{ with ($.Scratch.Get "c-language") }}{{ . }}{{ end }}">
<figcaption>
{{ if and (($.Scratch.Get "c-url") ($.Scratch.Get "c-title")) }}
<span>{{ $.Scratch.Get "c-title" }}</span><a href="{{ ($.Scratch.Get "c-url") | safeURL }}" target="_blank" rel="external">{{ $.Scratch.Get "c-link-text" | default ($.Scratch.Get "c-title") }}</a>
{{ else if $.Scratch.Get "c-title" }}
<span>{{ $.Scratch.Get "c-title" }}</span>
{{ end }}
</figcaption>
<table>
<tbody>
<tr>
<td class="gutter">
<pre>{{ range $index,$value := (split $trimmedContent "\n") }}<span class="line">{{ add $index 1 }}</span><br>{{ end }}</pre>
</td>
<td class="code">
<pre class="code-highlight language-{{ $.Scratch.Get "c-language" }}"><code class="{{ $.Scratch.Get "c-language" }}">{{ $trimmedContent }}</code></pre>
</td>
</tr>
</tbody>
</table>
</figure>
|