From 8b32e2e9a470f120a7913f66207c768516e212f0 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Tue, 28 Dec 2021 12:40:42 +0100 Subject: [PATCH] Add links to titles --- src/articles/static/public.css | 5 +++++ src/articles/utils.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/articles/static/public.css b/src/articles/static/public.css index d131159..60c1290 100644 --- a/src/articles/static/public.css +++ b/src/articles/static/public.css @@ -40,3 +40,8 @@ a.tag:not(:first-of-type):before { font-size: 1.2rem; padding: 8px 16px; } + +.toclink { + color: var(--nc-tx-1); + text-decoration: none; +} diff --git a/src/articles/utils.py b/src/articles/utils.py index 224b84c..e6add25 100644 --- a/src/articles/utils.py +++ b/src/articles/utils.py @@ -4,6 +4,7 @@ import markdown from bs4 import BeautifulSoup from django.conf import settings from markdown.extensions.codehilite import CodeHiliteExtension +from markdown.extensions.toc import TocExtension from articles.markdown import LazyLoadingImageExtension @@ -20,6 +21,7 @@ def format_article_content(content): extensions=[ "extra", "admonition", + TocExtension(anchorlink=True), CodeHiliteExtension(linenums=False, guess_lang=False), LazyLoadingImageExtension(), ]