summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ilvokhin <d@ilvokhin.com>2023-07-16 12:09:20 +0100
committerDmitry Ilvokhin <d@ilvokhin.com>2023-07-16 12:09:20 +0100
commitbc866494f7b77eebe7950f4dcf076616c181bd32 (patch)
tree33ac2cf52627521ed3255988ced97edddf52efa0
parent81877e175b467d615bc83498423274e01e211ad9 (diff)
downloadblog-bc866494f7b77eebe7950f4dcf076616c181bd32.tar.gz
blog-bc866494f7b77eebe7950f4dcf076616c181bd32.tar.bz2
blog-bc866494f7b77eebe7950f4dcf076616c181bd32.zip
Add table of context and addressable headers
Sometimes it's useful to highlight content of the post beforehand. Also, it's just nice to have a clickable headers in the document to simplify sharing of specific section.
-rw-r--r--blog/render.py5
-rw-r--r--posts/libstdc++-std-unordered-map/libstdc++-unordered-map.md4
-rw-r--r--share/style.css8
3 files changed, 16 insertions, 1 deletions
diff --git a/blog/render.py b/blog/render.py
index cdd018f..ad06602 100644
--- a/blog/render.py
+++ b/blog/render.py
@@ -1,5 +1,7 @@
import markdown
+from markdown.extensions.toc import TocExtension
+
def read_file_content(filename: str) -> str:
with open(filename) as f:
@@ -13,4 +15,5 @@ def write_file_content(filename: str, data: str) -> None:
def to_html(filename: str) -> str:
text = read_file_content(filename)
- return markdown.markdown(text, extensions=["fenced_code", "footnotes"])
+ return markdown.markdown(text, extensions=["fenced_code", "footnotes",
+ TocExtension(anchorlink=True)])
diff --git a/posts/libstdc++-std-unordered-map/libstdc++-unordered-map.md b/posts/libstdc++-std-unordered-map/libstdc++-unordered-map.md
index a1ddad2..bb39544 100644
--- a/posts/libstdc++-std-unordered-map/libstdc++-unordered-map.md
+++ b/posts/libstdc++-std-unordered-map/libstdc++-unordered-map.md
@@ -1,3 +1,7 @@
+[TOC]
+
+## Introduction
+
We all love maps. We love hash maps even more. They should be fast and
help to solve a large number of problems. Do you ever wonder about how they are
working under the hood? In this post I am going to explore implementation
diff --git a/share/style.css b/share/style.css
index 3d41f16..59001fd 100644
--- a/share/style.css
+++ b/share/style.css
@@ -115,3 +115,11 @@ ul.posts time {
ul.posts li a:visited {
color: #8b6fcb;
}
+
+.toclink {
+ color: #222;
+}
+
+.toclink:hover {
+ text-decoration: none;
+}