27 lines
1.6 KiB
HTML
27 lines
1.6 KiB
HTML
<!-- Use the array of pages passed as a param -->
|
|
{{ range . -}}
|
|
<!-- Don't process empty content files -->
|
|
{{- if ne (len .Content) 0 -}}
|
|
<!-- Remove the <hr /> tag generated by blackfriday for footnotes -->
|
|
{{- $content := replace .Content "<div class=\"footnotes\">\n\n<hr />" "<div class=\"footnotes\">" -}}
|
|
<!-- <code> blocks processed by Hugo's highlighter have a data-lang attribute. For those, we disable -->
|
|
<!-- highlight.js by changing the language class to "nohighlight", and adding "data-noescape". -->
|
|
{{- $content := replaceRE `<code class="language-\w+"\s+data-lang="\w+"` `<code class="nohighlight" data-noescape` $content -}}
|
|
<!-- enable Highlight.js line numbers when the markdown code block language selection is followed by "{}" e.g. ```js{} -->
|
|
{{- $content := replaceRE `(<code class="language-\w+){}(">)` `$1" data-line-numbers>` $content -}}
|
|
<!-- enable Highlight.js line highlights when the language selection is followed by "{<line numbers>}" e.g. ```js{1,5-7} -->
|
|
{{- $content := replaceRE `(<code class="language-\w+){(\S+)}(">)` `$1" data-line-numbers="$2">` $content -}}
|
|
<!-- Support both <hr /> (blackfriday) and <hr> (mmark) -->
|
|
{{- $content := replace $content "<hr>" "<hr />" -}}
|
|
<!-- Split the processed content by <hr /> tag -->
|
|
{{- range (split $content "<hr />") -}}
|
|
<!-- Only wrap in <section> tag if not already wrapped by shortcode -->
|
|
{{- if not (in . "data-noprocess") -}}
|
|
<section>
|
|
{{- end -}}
|
|
{{- . | safeHTML -}}
|
|
</section>
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end }}
|