aboutsummaryrefslogtreecommitdiff
path: root/template/doc.tmpl
diff options
context:
space:
mode:
Diffstat (limited to 'template/doc.tmpl')
-rw-r--r--template/doc.tmpl86
1 files changed, 86 insertions, 0 deletions
diff --git a/template/doc.tmpl b/template/doc.tmpl
new file mode 100644
index 0000000..549ba88
--- /dev/null
+++ b/template/doc.tmpl
@@ -0,0 +1,86 @@
+{{/* This doc template is given to the present tool to format articles. */}}
+
+{{define "root"}}
+
+ {{with .Subtitle}}<h2>{{.}}</h2>{{end}}
+ {{if .Doc | sectioned}}
+ {{with $toc := .Sections}}
+ <div id="toc">
+ {{template "TOC" .}}
+ </div>
+ {{end}}
+ {{end}}
+ {{if .Doc | sectioned}}
+ {{range .Sections}}
+ {{elem $.Template .}}
+ {{end}}
+ {{else}}
+ {{with index .Sections 0}}
+ {{range .Elem}}
+ {{elem $.Template .}}
+ {{end}}
+ {{end}}
+ {{end}}
+
+{{end}}
+
+{{define "TOC"}}
+ <ul>
+ {{range .}}
+ <li><a href="#TOC_{{.FormattedNumber}}">{{.Title}}</a></li>
+ {{with .Sections}}{{template "TOC" .}}{{end}}
+ {{end}}
+ </ul>
+{{end}}
+
+{{define "newline"}}
+{{/* No automatic line break. Paragraphs are free-form. */}}
+{{end}}
+
+{{define "section"}}
+ <h{{len .Number}} id="TOC_{{.FormattedNumber}}">{{.Title}}</h{{len .Number}}>
+ {{range .Elem}}{{elem $.Template .}}{{end}}
+{{end}}
+
+{{define "list"}}
+ <ul>
+ {{range .Bullet}}
+ <li>{{style .}}</li>
+ {{end}}
+ </ul>
+{{end}}
+
+{{define "text"}}
+ {{if .Pre}}
+ <div class="code"><pre>{{range .Lines}}{{.}}{{end}}</pre></div>
+ {{else}}
+ <p>
+ {{range $i, $l := .Lines}}{{if $i}}{{template "newline"}}
+ {{end}}{{style $l}}{{end}}
+ </p>
+ {{end}}
+{{end}}
+
+{{define "code"}}
+ {{if .Play}}
+ <div class="playground">{{.Text}}</div>
+ {{else}}
+ <div class="code">{{.Text}}</div>
+ {{end}}
+{{end}}
+
+{{define "image"}}
+<div class="image">
+ <img src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}}>
+</div>
+{{end}}
+
+{{define "iframe"}}
+<div class="iframe">
+ <iframe src="{{.URL}}"{{with .Height}} height="{{.}}"{{end}}{{with .Width}} width="{{.}}"{{end}} frameborder="0" allowfullscreen mozallowfullscreen webkitallowfullscreen></iframe>
+</div>
+{{end}}
+
+{{define "link"}}<p class="link"><a href="{{.URL}}" target="_blank">{{style .Label}}</a></p>{{end}}
+
+{{define "html"}}{{.HTML}}{{end}}