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

122 lines
3.9 KiB
HTML
Raw Normal View History

2023-09-27 10:58:42 -06:00
<!--
=======
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-->
2023-10-13 22:20:39 -06:00
{{ $content := $content | replaceRE "\\{" "\\{" }}
{{ $content := $content | replaceRE "\\}" "\\}" }}
<!-- the above two commands allow curly braces to show up properly, for example in Laplace
transforms. -->
{{ $content := $content | replaceRE "\\," "\\," }}
<!-- the above commands helps with keeping the perserving "\," Often used in integrals to make a small gap before the dx term.-->
2023-09-27 10:58:42 -06:00
<!--
====
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 }}