summaryrefslogtreecommitdiffstats
path: root/templates/content.html
blob: 73f18c7aeeac745a3b46446a10b946662d13507e (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
94
95
96
97
{{- 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 .Rows -}}
		{{- 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"}}{{range .Contents.Paragraphs -}}
<p class="cnm-text">{{.}}</p>
	{{- end}}{{end -}}
	{{- if eq .Format "fmt" -}}
	{{- range .Contents.Paragraphs -}}
	{{- cnmfmt . -}}
	{{- end -}}
	{{- end -}}
	{{- if not (eq .Format "" "plain" "fmt") -}}
<pre class="cnm-text cnm-text-pre">{{.Contents.Text}}</pre>
	{{- end -}}
{{- end -}}

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