Add section anchors.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2020-02-25 14:59:08 +00:00
parent 36cf64abc3
commit ef117e9874
4 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,6 @@
<https://commons.wikimedia.org/wiki/File:Chain_link_icon.svg>
(c) Mun May Tee-Galloway <https://commons.wikimedia.org/wiki/User:MGalloway_(WMF)>
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
The image was rotated, changed from black to blue, and converted to PNG.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -131,6 +131,18 @@ a:hover {
text-decoration: underline;
}
span.section-anchor {
opacity: 0;
}
span.section-anchor:hover {
opacity: 1;
}
span.section-heading:hover + span {
opacity: 1;
}
a.footnote_reference::before {
content: "[";
}

View File

@ -1,6 +1,11 @@
#!/bin/sh
sed -i.sedbak 's|</head>|<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="css/style.css"></head>|' $@
sed -i.sedbak 's|<a href="\([^":]*\).rst">|<a href="\1">|' $@
sed -i.sedbak 's|<a href="\([^":]*\).rst">|<a href="\1">|g' $@
sed -i.sedbak 's|http://cdn.mathjax.org/mathjax/latest/MathJax.js|https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js|' $@
# First put <section id="..."> and <hN>...</hN> on the same line. <https://unix.stackexchange.com/a/337399/82702>
sed -i.sedbak -n '$!N;s|<section id="\([^"]*\)">\s*\n\s*<h|<section id="\1"><h|;P;D' $@
sed -i.sedbak 's|<section id="\([^"]*\)"><h\([1-9]\)>\([^<]*\)</h\([1-9]\)>|<section id="\1"><h\2><span class="section-heading">\3</span><span class="section-anchor"> <a href="#\1"><img width="24" height="24" src="assets/images/section-anchor.png"></a></span></h\4>|' $@
rm -f *.sedbak