counting headers is now part of hugo templates
This commit is contained in:
parent
310b0de2c9
commit
c2856146f2
11 changed files with 49 additions and 259 deletions
|
@ -576,6 +576,10 @@ img, video {
|
|||
padding-left: 0.1em;
|
||||
}
|
||||
|
||||
.counters {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
|
||||
.rightcolumn {
|
||||
/* display: grid;
|
||||
grid-column: 2;
|
||||
|
@ -731,66 +735,6 @@ h2 + p:first-letter {
|
|||
font-weight: 400;
|
||||
}
|
||||
|
||||
body {
|
||||
counter-reset: h2 glossN;
|
||||
}
|
||||
|
||||
h2 {
|
||||
counter-reset: h3;
|
||||
}
|
||||
|
||||
h3 {
|
||||
counter-reset: h4;
|
||||
}
|
||||
|
||||
h4 {
|
||||
counter-reset: h5;
|
||||
}
|
||||
|
||||
h5 {
|
||||
counter-reset: h6;
|
||||
}
|
||||
|
||||
h2:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h2;
|
||||
content: counter(h2) ". ";
|
||||
}
|
||||
|
||||
h3:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h3;
|
||||
content: counter(h2) "." counter(h3) ". ";
|
||||
}
|
||||
|
||||
h4:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h4;
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) ". ";
|
||||
}
|
||||
|
||||
h5:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h5;
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". ";
|
||||
}
|
||||
|
||||
h6:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h6;
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "."
|
||||
counter(h6) ". ";
|
||||
}
|
||||
|
||||
h2.nocount:before,
|
||||
h3.nocount:before,
|
||||
h4.nocount:before,
|
||||
h5.nocount:before,
|
||||
h6.nocount:before {
|
||||
content: "";
|
||||
counter-increment: none;
|
||||
}
|
||||
|
||||
details {
|
||||
padding-left: 1rem;
|
||||
}
|
||||
|
|
|
@ -401,6 +401,9 @@ ol li {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.counters {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
/* #TableOfContents > ol:first-child > span > li > a::after { */
|
||||
/* content: "¶"; */
|
||||
/* color: rgba(0, 0, 0, 0.2); */
|
||||
|
@ -556,67 +559,6 @@ blockquote {
|
|||
font-family: "Gentium Plus", serif;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
body {
|
||||
counter-reset: h2 glossN;
|
||||
}
|
||||
|
||||
h2 {
|
||||
counter-reset: h3;
|
||||
}
|
||||
|
||||
h3 {
|
||||
counter-reset: h4;
|
||||
}
|
||||
|
||||
h4 {
|
||||
counter-reset: h5;
|
||||
}
|
||||
|
||||
h5 {
|
||||
counter-reset: h6;
|
||||
}
|
||||
|
||||
h2:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h2;
|
||||
content: counter(h2) ". ";
|
||||
}
|
||||
|
||||
h3:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h3;
|
||||
content: counter(h2) "." counter(h3) ". ";
|
||||
}
|
||||
|
||||
h4:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h4;
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) ". ";
|
||||
}
|
||||
|
||||
h5:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h5;
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". ";
|
||||
}
|
||||
|
||||
h6:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: h6;
|
||||
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "."
|
||||
counter(h6) ". ";
|
||||
}
|
||||
|
||||
h2.nocount:before,
|
||||
h3.nocount:before,
|
||||
h4.nocount:before,
|
||||
h5.nocount:before,
|
||||
h6.nocount:before {
|
||||
content: "";
|
||||
counter-increment: none;
|
||||
}
|
||||
|
||||
details {
|
||||
padding-left: 1rem;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,59 +1,4 @@
|
|||
{{- define "singlebody" -}}
|
||||
{{ $cssTemplate := `.css-_rplc_-h2 {
|
||||
counter-reset: css-_rplc_-h3;
|
||||
}
|
||||
|
||||
.css-_rplc_-h3 {
|
||||
counter-reset: css-_rplc_-h4;
|
||||
}
|
||||
|
||||
.css-_rplc_-h4 {
|
||||
counter-reset: css-_rplc_-h5;
|
||||
}
|
||||
|
||||
.css-_rplc_-h5 {
|
||||
counter-reset: css-_rplc_-h6;
|
||||
}
|
||||
|
||||
.css-_rplc_-h2:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h2 1;
|
||||
content: counter(css-_rplc_-h2) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h3:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h3 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h4:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h4 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h5:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h5 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) "." counter(css-_rplc_-h5) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h6:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h6 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) "." counter(css-_rplc_-h5) "."
|
||||
counter(css-_rplc_-h6) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h2.nocount:before,
|
||||
.css-_rplc_-h3.nocount:before,
|
||||
.css-_rplc_-h4.nocount:before,
|
||||
.css-_rplc_-h5.nocount:before,
|
||||
.css-_rplc_-h6.nocount:before {
|
||||
content: "";
|
||||
counter-increment: none;
|
||||
}` }}
|
||||
|
||||
{{ $cssOutput := "" }}
|
||||
{{ $cssHashes := "" }}
|
||||
|
@ -74,8 +19,6 @@
|
|||
{{ end }}
|
||||
<div class="runningTitle"><span class="sup">{{ substr $p.File.Dir 0 -1 }}⁄</span><a href="#ph-{{ $p.File.UniqueID }}">{{ $tit }}</a></div>
|
||||
<div class="content">{{ $p.Content }}</div>
|
||||
{{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" $p.File.UniqueID) }}
|
||||
{{ $cssHashes = printf "%s css-%s-h2" $cssHashes $p.File.UniqueID }}
|
||||
|
||||
{{ range $scratch.has_children }}
|
||||
<div class="crustpage">
|
||||
|
@ -102,8 +45,6 @@
|
|||
{{ partial "printsinglebody.html" . }}
|
||||
{{ .Content }}
|
||||
{{ .Scratch.Set "alreadyRendered" true }}
|
||||
{{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" .File.UniqueID) }}
|
||||
{{ $cssHashes = printf "%s css-%s-h2" $cssHashes .File.UniqueID }}
|
||||
|
||||
{{end}}
|
||||
{{ $kid := $s.Get (printf "/%s" .File) }}
|
||||
|
@ -137,8 +78,6 @@
|
|||
{{ end }}
|
||||
|
||||
{{ .Scratch.Set "alreadyRendered" true }}
|
||||
{{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" .File.UniqueID) }}
|
||||
{{ $cssHashes = printf "%s css-%s-h2" $cssHashes .File.UniqueID }}
|
||||
{{ end }}
|
||||
{{end}}
|
||||
{{ end }}
|
||||
|
@ -156,8 +95,4 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $cssOutput = printf "body {counter-reset: %s;}\n%s" $cssHashes $cssOutput }}
|
||||
{{ $var := $cssOutput | resources.FromString "css/dyn.css" }}
|
||||
{{ $dummy := $var.Permalink }}
|
||||
{{- end -}}
|
||||
|
|
|
@ -1 +1,30 @@
|
|||
<h{{ add 1 .Level }} id="{{ .Anchor | safeURL }}" class="hx css-{{ .Page.File.UniqueID }}-h{{ add 1 .Level }}">{{ .Text | safeHTML }}<a class="hpar" href="#{{ .Anchor | safeURL }}">¶</a></h{{ add 1 .Level }}>
|
||||
{{ $currentLevel := .Level }}
|
||||
{{ $currentHeaderKey := printf "H_%d" $currentLevel }}
|
||||
|
||||
{{ if not (.Page.Scratch.Get $currentHeaderKey) }}
|
||||
{{ .Page.Scratch.Set $currentHeaderKey 1 }}
|
||||
{{ else }}
|
||||
{{ .Page.Scratch.Set $currentHeaderKey (add 1 (.Page.Scratch.Get $currentHeaderKey)) }}
|
||||
{{ end }}
|
||||
|
||||
{{ if .Page.Scratch.Get "previousLevel" }}
|
||||
{{ $previousLevel := .Page.Scratch.Get "previousLevel" }}
|
||||
{{ if gt $previousLevel $currentLevel }}
|
||||
{{ range $header := slice 1 2 3 4 5 6 }}
|
||||
{{ if gt $header $currentLevel }}
|
||||
{{ $.Page.Scratch.Delete (printf "H_%d" $header) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $counter := "" }}
|
||||
{{ range $header := slice 1 2 3 4 5 6 }}
|
||||
{{ if gt ($.Page.Scratch.Get (printf "H_%d" $header)) 0 }}
|
||||
{{ $counter = printf "%s%d." $counter ($.Page.Scratch.Get (printf "H_%d" $header))}}
|
||||
{{ end }}
|
||||
{{end}}
|
||||
|
||||
<h{{ add 1 .Level }} id="{{ .Anchor | safeURL }}" class="hx css-{{ .Page.File.UniqueID }}-h{{ add 1 .Level }}"><span class="counters">{{ $counter }} </span>{{ .Text | safeHTML }}<a class="hpar" href="#{{ .Anchor | safeURL }}">¶</a> {{ .Page.Scratch.Get "level" }}</h{{ add 1 .Level }}>
|
||||
|
||||
{{ .Page.Scratch.Set "previousLevel" .Level }}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<link href="/css/paged_interface.css" rel="stylesheet" type="text/css">
|
||||
<link href="/css/dyn.css" rel="stylesheet" type="text/css">
|
||||
<link href="/css/print.css" rel="stylesheet" type="text/css">
|
||||
<script src="/js/paged.polyfill.js"></script>
|
||||
<script src="/js/pagedjsCustomizations.js"></script>
|
||||
|
|
|
@ -1,60 +1,4 @@
|
|||
{{- define "singlebody" -}}
|
||||
{{ $cssTemplate := `.css-_rplc_-h2 {
|
||||
counter-reset: css-_rplc_-h3;
|
||||
}
|
||||
|
||||
.css-_rplc_-h3 {
|
||||
counter-reset: css-_rplc_-h4;
|
||||
}
|
||||
|
||||
.css-_rplc_-h4 {
|
||||
counter-reset: css-_rplc_-h5;
|
||||
}
|
||||
|
||||
.css-_rplc_-h5 {
|
||||
counter-reset: css-_rplc_-h6;
|
||||
}
|
||||
|
||||
.css-_rplc_-h2:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h2 1;
|
||||
content: counter(css-_rplc_-h2) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h3:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h3 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h4:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h4 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h5:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h5 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) "." counter(css-_rplc_-h5) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h6:before {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
counter-increment: css-_rplc_-h6 1;
|
||||
content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) "." counter(css-_rplc_-h5) "."
|
||||
counter(css-_rplc_-h6) ". ";
|
||||
}
|
||||
|
||||
.css-_rplc_-h2.nocount:before,
|
||||
.css-_rplc_-h3.nocount:before,
|
||||
.css-_rplc_-h4.nocount:before,
|
||||
.css-_rplc_-h5.nocount:before,
|
||||
.css-_rplc_-h6.nocount:before {
|
||||
content: "";
|
||||
counter-increment: none;
|
||||
}` }}
|
||||
|
||||
{{ $cssOutput := "" }}
|
||||
{{ $cssHashes := "" }}
|
||||
|
||||
|
@ -85,9 +29,7 @@
|
|||
|
||||
<div class="print0">{{ partial "printsinglebody.html" $p }}</div>
|
||||
<div class="content">{{ $p.Content }}</div>
|
||||
{{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" $p.File.UniqueID) }}
|
||||
{{ $cssHashes = printf "%s css-%s-h2" $cssHashes $p.File.UniqueID }}
|
||||
|
||||
|
||||
{{ range $scratch.has_children }}
|
||||
<div class="crustpage">
|
||||
{{ $addS := 0 }}
|
||||
|
@ -120,8 +62,6 @@
|
|||
<div class="runningTitle"><span class="sup">{{ index $scratch.crust 0 }}⁄</span><a href="#ph-{{ .File.UniqueID }}">{{ $tit }}</a></div>
|
||||
{{ partial "printsinglebody.html" . }}
|
||||
{{ .Content }}
|
||||
{{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" .File.UniqueID) }}
|
||||
{{ $cssHashes = printf "%s css-%s-h2" $cssHashes .File.UniqueID }}
|
||||
{{ $kid := $s.Get (printf "/%s" .File) }}
|
||||
{{ range $kid.has_children }}
|
||||
<div class="crustpage">
|
||||
|
@ -146,8 +86,6 @@
|
|||
<div class="runningTitle"><span class="sup">{{ index $scratch.crust 0 }}⁄</span><a href="#ph-{{ .File.UniqueID }}">{{ $tit }}</a></div>
|
||||
{{ partial "printsinglebody.html" . }}
|
||||
{{ .Content }}
|
||||
{{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" .File.UniqueID) }}
|
||||
{{ $cssHashes = printf "%s css-%s-h2" $cssHashes .File.UniqueID }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
@ -172,7 +110,4 @@
|
|||
</div></div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $cssOutput = printf "body {counter-reset: %s;}\n%s" $cssHashes $cssOutput }}
|
||||
{{ $var := $cssOutput | resources.FromString "css/dyn.css" }}
|
||||
{{ $dummy := $var.Permalink }}
|
||||
{{- end -}}
|
||||
|
|
13
static/js/paged.polyfill.js
Normal file → Executable file
13
static/js/paged.polyfill.js
Normal file → Executable file
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @license Paged.js v0.4.0 | MIT | https://gitlab.pagedmedia.org/tools/pagedjs
|
||||
* @license Paged.js v0.4.1 | MIT | https://gitlab.pagedmedia.org/tools/pagedjs
|
||||
*/
|
||||
|
||||
(function (global, factory) {
|
||||
|
@ -27116,13 +27116,20 @@
|
|||
counter-reset: unset;
|
||||
}
|
||||
|
||||
[data-footnote-marker]:not([data-split-from]) {
|
||||
counter-increment: footnote-marker;
|
||||
[data-footnote-marker] {
|
||||
text-indent: 0;
|
||||
display: list-item;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
[data-footnote-marker][data-split-from] {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
[data-footnote-marker]:not([data-split-from]) {
|
||||
counter-increment: footnote-marker;
|
||||
}
|
||||
|
||||
[data-footnote-marker]::marker {
|
||||
content: counter(footnote-marker) ". ";
|
||||
}
|
||||
|
|
0
static/js/pagedjsCustomizations.js
Normal file → Executable file
0
static/js/pagedjsCustomizations.js
Normal file → Executable file
0
static/js/popcorn.min.js
vendored
Normal file → Executable file
0
static/js/popcorn.min.js
vendored
Normal file → Executable file
0
static/js/soundcite.min.js
vendored
Normal file → Executable file
0
static/js/soundcite.min.js
vendored
Normal file → Executable file
Loading…
Add table
Reference in a new issue