53 lines
No EOL
1.4 KiB
HTML
53 lines
No EOL
1.4 KiB
HTML
{{- $result := transform.HighlightCodeBlock . }}
|
|
{{- $caption := .Attributes.caption }}
|
|
{{- $title := .Attributes.title }}
|
|
{{- if $caption }}
|
|
{{- printf "<!-- begin figure with codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
|
|
<figure class="figure-with-codeblock"{{if $title}} title="{{$title}}"{{end}}>
|
|
{{ with $title }}<header class="codeblock__header"><p class="codeblock__title">{{.}}</p></header>{{ end }}
|
|
<div class="codeblock highlight">
|
|
<pre class="chroma">
|
|
{{
|
|
(
|
|
replaceRE
|
|
`(?s)<span class="gi">(.*?)</span>`
|
|
`<ins class="gi">$1</ins>`
|
|
(
|
|
replaceRE
|
|
`(?s)<span class="gd">(.*?)</span>`
|
|
`<del class="gd">$1</del>`
|
|
$result.Inner
|
|
)
|
|
) | safeHTML
|
|
}}
|
|
</pre>
|
|
</div>
|
|
<figcaption>{{$caption | markdownify}}</figcaption>
|
|
</figure>
|
|
{{ printf "<!-- end figure with codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
|
|
{{ else }}{{/* not a figure, just a regular codeblock */}}
|
|
{{- printf "<!-- begin codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
|
|
<article class="codeblock highlight">
|
|
{{- with $title }}
|
|
<header class="codeblock__header">
|
|
<p class="codeblock__title">{{.}}</p>
|
|
</header>
|
|
{{- end }}
|
|
<pre class="chroma">
|
|
{{
|
|
(
|
|
replaceRE
|
|
`(?s)<span class="gi">(.*?)</span>`
|
|
`<ins class="gi">$1</ins>`
|
|
(
|
|
replaceRE
|
|
`(?s)<span class="gd">(.*?)</span>`
|
|
`<del class="gd">$1</del>`
|
|
$result.Inner
|
|
)
|
|
) | safeHTML
|
|
}}
|
|
</pre>
|
|
</article>
|
|
{{- printf "<!-- end codeblock %s -->" (string (add .Ordinal 1)) | safeHTML }}
|
|
{{ end }} |