summaryrefslogtreecommitdiffstats
path: root/templates/content.html
blob: 4616a1057855abd86e75e898335628c0c8b81aee (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{{- if eq .Name "section" "content" -}}
{{- if .Title}}
<section class="cnm-section"><details open>
		{{- inc .Title -}}
		<summary>
			{{- with .Title -}}
			{{- if $l := lanchor -}}
			<h{{depth}}>{{.}}<a class="sec-link" id="/{{$l}}" href="#/{{$l}}"></a>
				{{- if $s := sanchor}}{{if ne $s $l}}<a id="#{{$s}}"></a>{{end}}{{end -}}
			</h{{depth}}>
			{{- end -}}
			{{- end -}}
		</summary>
		{{- range .Children -}}
			{{- template "content.html" . -}}
		{{- end -}}
		{{- dec -}}
</details></section>
{{else -}}
{{- range .Children -}}
	{{- template "content.html" . -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- if eq .Name "list" -}}
{{if .Ordered}}<ol{{else}}<ul{{end}} class="cnm-list">
	{{- range .Children -}}
		{{- if eq .Name "list" -}}
		{{- template "content.html" . -}}
		{{- else -}}
		<li>{{- template "content.html" . -}}</li>
		{{- end -}}
	{{- end -}}
{{- if .Ordered}}</ol>{{else}}</ul>{{end -}}
{{- end -}}

{{- if eq .Name "table" -}}
<table class="cnm-table">
	{{- range .Children -}}
		{{- template "content.html" . -}}
	{{- end -}}
</table>
{{- end -}}

{{- if eq .Name "header" -}}
<tr class="cnm-header">
	{{- range .Children -}}
	<th>{{template "content.html" .}}</th>
	{{- end -}}
</tr>
{{- end -}}

{{- if eq .Name "row" -}}
<tr class="cnm-row">
	{{- range .Children -}}
	<td>{{template "content.html" .}}</td>
	{{- end -}}
</tr>
{{- end -}}

{{- if eq .Name "embed" -}}
<figure class="cnm-embed">
	{{- if eq .Type "image/png" "image/jpeg" "image/webp" "image/*" -}}
	<a href="{{tourl .URL}}"><img src="{{tourl .URL}}" alt="{{with .Description}}{{.}}{{else}}embedded {{.Type}}{{end}}" {{with .Description}}title="{{.}}" {{end}}/></a>
	{{- end -}}
	{{- if eq .Type "video/mp4" "video/webm" "video/*" -}}
	<video src="{{tourl .URL}}" controls{{with .Description}} title="{{.}}"{{end}}>
		Video content: <a href="{{tourl .URL}}">{{.URL}}</a>
	</video>
	{{- end -}}
	{{- if not (eq .Type "image/png" "image/jpeg" "image/webp" "image/*" "video/mp4" "video/webm" "video/*") -}}
	<p>
		Embedded <code>{{.Type}}</code> content: <a href="{{tourl .URL}}"{{with .Description}} title="{{.}}"{{end}}>{{.URL}}</a>
	</p>
	{{- end -}}
	{{- with .Description}}<figcaption>{{.}}</figcaption>{{end -}}
</figure>
{{- end -}}

{{- if eq .Name "text" -}}
	{{- if eq .Format "" "plain" "pre" "fmt" -}}
		{{- if eq .Format "" "plain"}}{{range .Contents.Paragraphs}}<p class="cnm-text">{{.}}</p>{{end}}{{end -}}
		{{- if eq .Format "pre"}}<pre class="cnm-text cnm-text-pre">{{.Contents.Text}}</pre>{{end -}}
		{{- if eq .Format "fmt"}}{{range .Contents.Paragraphs}}{{cnmfmt .}}{{end}}{{end -}}
	{{- else -}}
		<pre class="cnm-text cnm-text-raw">{{.Contents.Text}}</pre>
	{{- end -}}
{{- end -}}

{{- if eq .Name "raw" -}}
<pre class="cnm-raw"><code class="cnm-raw-{{lang .Syntax}}">{{.Contents.Text}}</code></pre>
{{- end -}}