doc: add anchor links to headings
This commit is contained in:
parent
861a723ebc
commit
58ee0bdc1b
@ -8,7 +8,7 @@
|
|||||||
# Pandoc flags
|
# Pandoc flags
|
||||||
FLAGS = --filter pandoc-crossref --citeproc --toc --number-sections
|
FLAGS = --filter pandoc-crossref --citeproc --toc --number-sections
|
||||||
PDF_FLAGS = --pdf-engine=xelatex
|
PDF_FLAGS = --pdf-engine=xelatex
|
||||||
HTML_FLAGS = --standalone --katex$(KATEX_URL)
|
HTML_FLAGS = --standalone --katex$(KATEX_URL) --lua-filter filters/add-anchors.lua
|
||||||
|
|
||||||
# Rebuild everything if the makefile changed
|
# Rebuild everything if the makefile changed
|
||||||
.EXTRA_PREREQS += Makefile
|
.EXTRA_PREREQS += Makefile
|
||||||
|
14
doc/filters/add-anchors.lua
Normal file
14
doc/filters/add-anchors.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
-- Adds anchor links to headings with IDs
|
||||||
|
function Header (h)
|
||||||
|
if h.identifier ~= '' then
|
||||||
|
-- an empty link to this header
|
||||||
|
local anchor_link = pandoc.Link(
|
||||||
|
{}, -- content
|
||||||
|
'#' .. h.identifier, -- href
|
||||||
|
'', -- title
|
||||||
|
{class = 'anchor'} -- attributes
|
||||||
|
)
|
||||||
|
h.content:insert(1, anchor_link)
|
||||||
|
return h
|
||||||
|
end
|
||||||
|
end
|
@ -3,12 +3,35 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Make headings smaller */
|
/* Make headings smaller */
|
||||||
h1 { font-size: 1.8em }
|
h1 { font-size: 1.8em }
|
||||||
h2 { font-size: 1.4em }
|
h2 { font-size: 1.4em }
|
||||||
h3 { font-size: 1.1em }
|
h3 { font-size: 1.1em }
|
||||||
h1, h2, h3 { margin: 1em 0 }
|
h1, h2, h3 { margin: 1em 0 }
|
||||||
|
|
||||||
|
/* Heading anchors */
|
||||||
|
.anchor::before {
|
||||||
|
content: '🔗';
|
||||||
|
font-size: 80%;
|
||||||
|
opacity: 0;
|
||||||
|
margin-right: -1.1em;
|
||||||
|
position: relative;
|
||||||
|
left: -1.2em;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.header-section-number,
|
||||||
|
.anchor::before { transition: opacity 0.3s ease 0.1s }
|
||||||
|
.anchor { text-decoration: none }
|
||||||
|
|
||||||
|
h1:hover > .anchor::before,
|
||||||
|
h2:hover > .anchor::before,
|
||||||
|
h3:hover > .anchor::before { opacity: 1; }
|
||||||
|
h1:hover > .header-section-number,
|
||||||
|
h2:hover > .header-section-number,
|
||||||
|
h3:hover > .header-section-number { opacity: 0; }
|
||||||
|
|
||||||
|
|
||||||
/* Match math and normal mode fonts */
|
/* Match math and normal mode fonts */
|
||||||
body { font-size: 1.1em }
|
body { font-size: 1.1em }
|
||||||
.katex { font-size: 1.0em !important }
|
.katex { font-size: 1.0em !important }
|
||||||
|
Loading…
Reference in New Issue
Block a user