aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/rst
diff options
context:
space:
mode:
Diffstat (limited to 'pysite/rst')
-rw-r--r--pysite/rst/__init__.py16
-rw-r--r--pysite/rst/directives/__init__.py1
-rw-r--r--pysite/rst/roles.py3
3 files changed, 14 insertions, 6 deletions
diff --git a/pysite/rst/__init__.py b/pysite/rst/__init__.py
index 74f19285..97a77f40 100644
--- a/pysite/rst/__init__.py
+++ b/pysite/rst/__init__.py
@@ -1,4 +1,3 @@
-# coding=utf-8
import re
from docutils.core import publish_parts
@@ -68,12 +67,23 @@ def render(rst: str):
if depth == 1: # Top-level header, so just store it in the current header
current_header["id"] = match.group(1)
- current_header["title"] = match.group(2)
+
+ title = match.group(2)
+
+ if title.startswith("<i"): # We've found an icon, which needs to have a space after it
+ title = title.replace("</i> ", "</i> &nbsp;")
+
+ current_header["title"] = title
else: # Second-level (or deeper) header, should be stored in a list of sub-headers under the current
sub_headers = current_header.get("sub_headers", [])
+ title = match.group(2)
+
+ if title.startswith("<i"): # We've found an icon, which needs to have a space after it
+ title = title.replace("</i> ", "</i> &nbsp;")
+
sub_headers.append({
"id": match.group(1),
- "title": match.group(2)
+ "title": title
})
current_header["sub_headers"] = sub_headers
diff --git a/pysite/rst/directives/__init__.py b/pysite/rst/directives/__init__.py
index 9bad5790..e69de29b 100644
--- a/pysite/rst/directives/__init__.py
+++ b/pysite/rst/directives/__init__.py
@@ -1 +0,0 @@
-# coding=utf-8
diff --git a/pysite/rst/roles.py b/pysite/rst/roles.py
index acba31e4..abade243 100644
--- a/pysite/rst/roles.py
+++ b/pysite/rst/roles.py
@@ -1,4 +1,3 @@
-# coding=utf-8
from docutils import nodes
from docutils.parsers.rst.roles import set_classes
from docutils.parsers.rst.states import Inliner
@@ -41,7 +40,7 @@ def icon_role(_role: str, rawtext: str, text: str, lineno: int, inliner: Inliner
return [prb], [msg]
- html = f"""<i class="uk-icon {weight} fa-{parts[1]}"></i>"""
+ html = f"""<i class="uk-icon fa-fw {weight} fa-{parts[1]}"></i>"""
node = nodes.raw(html, html, format="html", **options)
return [node], []