Markdown pages
Markdown page templates are provided additional .Markdown field on top of usual contents of TemplateContent. Markdown field contains two fields:
.Content: This is the HTML equiavalent of the content of*.mdfile that is the"markdown-page"is currently called for. You are expected to write the content of this field to an appropriate place in your template..Toc: This is a tree of nodes, representing “Table of Contents”. Note that, since a markdown page is okay to have more than oneH1title, the TOC starts with a dummy root, representing a H0 with no renderable title. You only need to iterate on its children to access H1s. Printing a Toc require recursive templating.
{{define "markdown-page"}}
<html>
<body>
<main>{{trustedHtml .Markdown.Content}}</main>
<aside>{{trustedHtml .Markdown.Toc}}</aside>
</body>
</html>
{{end}}
See the Escaping section for trustedHtml.
Link rewriting
To enable writers to link pages without minding how they will be translated into the build, Kask implicitly rewrites the found links as to make them point to the pages of files the original link points to.
Relative links have different variations. They can point to files in the parent directory, or in one of the contained directories. Consider the file /subdir/subsubdir/README.md has some links to other files in the content directory. This table shows how the links point to subdirectories will be rewritten:
| URL in input files | URL in output files |
|---|---|
. |
/subdir/subsubdir/ |
a |
/subdir/subsubdir/a/ |
a.md |
/subdir/subsubdir/a.html |
a/b.md |
/subdir/subsubdir/a/b.html |
a/README.md |
/subdir/subsubdir/a/ |
This table shows how the links to parent directory will be resolved:
| URL in input files | URL in output files |
|---|---|
.. |
/subdir/ |
../.. |
/ |
../../a.md |
/a.html |
../../README.md |
/ |
../a.md |
/subdir/a.html |
../README.md |
/subdir/ |
Kask also removes the redundancies in links, where the path is written with entering and exiting segments of one directory:
| URL in input files | URL in output files |
|---|---|
../subsubdir/a.md |
/subdir/subsubdir/a.html |
../subsubdir/a/b.md |
/subdir/subsubdir/a/b.html |
../subsubdir/a/README.md |
/subdir/subsubdir/a/ |
Additionally, a leading and trailing ./ wouldn’t change the results.
Also, Kask leaves external links as they are. Those start with http:// or https://.
