From bc866494f7b77eebe7950f4dcf076616c181bd32 Mon Sep 17 00:00:00 2001 From: Dmitry Ilvokhin Date: Sun, 16 Jul 2023 12:09:20 +0100 Subject: 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. --- blog/render.py | 5 ++++- posts/libstdc++-std-unordered-map/libstdc++-unordered-map.md | 4 ++++ share/style.css | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) 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; +} -- cgit v1.2.3-70-g09d2