MATH201/themes/zettels/layouts/partials/content.html

119 lines
3.7 KiB
HTML

<!--
=======
Wiklinks
=======
-->
{{ $firstBracket := "\\[\\[" }}
{{ $lastBracket := "\\]\\]" }}
{{ $matrixBreak := "\\\\\\\\"}}
{{ $wikiregex := "\\[\\[([^/]+?)\\]\\]" }}
{{ $wikilinks := .Content | findRE $wikiregex }}
{{ $.Scratch.Add "content" .RawContent }}
{{ range $wikilinks }}
{{ $content := . | replaceRE $wikiregex "$1" }}
{{ $content := $content | replaceRE "\\?" "\\?" }}
{{ $wikilink := printf "%s%s%s" $firstBracket $content $lastBracket }}
{{ $anchorized := $content | anchorize }}
{{ $link := printf "%s%s%s%s%s%s" "<a href=\"" $anchorized ".html" "\">" $content "</a>" }}
{{ $noteContent := $.Scratch.Get "content" | replaceRE $wikilink $link }}
{{ $.Scratch.Set "content" $noteContent }}
{{ end }}
{{ $content := .Scratch.Get "content" }}
{{ $content := $content | replaceRE "\n" "\n\n" }}
{{ $content := $content | replaceRE $matrixBreak "\\\\\\\\\\\\\\\\" }}
<!--The above command replaces a \\ in content/*.md files with a \\\\ yes it looks silly-->
{{ $content := $content | replaceRE "_" "\\_"}}
<!-- The above replaces _ with \_ inorder to prevent hugo turning subscripts into <em> tags-->
{{ $content := $content | replaceRE "\\{" "\\{" }}
{{ $content := $content | replaceRE "\\}" "\\}" }}
<!-- the above two commands allow curly braces to show up properly, for example in Laplace transforms. -->
<!--
====
TAGS
====
-->
<!--
===================================
Regular tags followed by a new line
===================================
#mytag/with-no-espaces
New line
-->
{{ $tagregexN := "#([^#\\s\\,:}]+)\\n" }}
<!--
===================================
Regular tags followed by a hashtag
===================================
#mytag/with-no-espaces
New line
-->
{{ $tagregexH := "#([^#\\s\\,:}]+)#" }}
<!--
======================
Tags containing spaces
======================
#mytag/with espaces#
-->
{{ $tagregexS := "#([^\\s^#][^#]*[^\\s^#])#" }}
<!--
============
Regular tags
============
#mytag
#mytag/could/be/nested
-->
{{ $tagregex := "[^/a-z]#([^#\\s\\,:}]+)" }}
{{ $content := $content | replaceRE $tagregexN "<a class=\"hashtag\" onclick=\"focusTag(this)\">$1</a>\n" | safeHTML }}
{{ $content := $content | replaceRE $tagregexS "<a class=\"hashtag\" onclick=\"focusTag(this)\">$1</a>" | safeHTML }}
{{ $content := $content | replaceRE $tagregexH "<a class=\"hashtag\" onclick=\"focusTag(this)\">$1</a>" | safeHTML }}
{{ $content := $content | replaceRE $tagregex "\n<a class=\"hashtag\" onclick=\"focusTag(this)\">$1</a>" | safeHTML }}
<!--
======================
Misc regex replacement
======================
-->
{{ $rightArrow := "<svg width=\"11px\" height=\"10px\" viewBox=\"0 0 11 10\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ><g id=\"right-arrow\" ><path d=\"M1.77635684e-14,5 L9,5\" id=\"rod\" stroke=\"#000000\" stroke-width=\"2\" ></path><path d=\"M11,5 L6,0.5 L6,9.5 L11,5 Z\" id=\"point\" fill=\"#000000\"></path></g></svg>" }}
{{ $leftArrow := "<svg width=\"11px\" height=\"10px\" viewBox=\"0 0 11 10\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"> <g id=\"left-arrow\" transform=\"translate(5.500000, 5.000000) scale(-1, 1) translate(-5.500000, -5.000000) \"> <path d=\"M1.77635684e-14,5 L9,5\" id=\"rod\" stroke=\"#000000\" stroke-width=\"2\"></path> <path d=\"M11,5 L6,0.5 L6,9.5 L11,5 Z\" id=\"point\" fill=\"#000000\"></path></g></svg>" }}
{{ $content := $content | replaceRE "->" $rightArrow }}
{{ $content := $content | replaceRE "<-" $leftArrow }}
{{ $content := $content | replaceRE "::([^/]+?)::" "<mark>$1</mark>" }}
{{ $content := $content | replaceRE "==([^/]+?)==" "<mark>$1</mark>" }}
{{ $content | markdownify }}