aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/rst/__init__.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-06-08 17:56:15 +0100
committerGravatar Gareth Coles <[email protected]>2018-06-08 17:56:15 +0100
commit60838b789f7e1a307751e13f45e62495dd65bd10 (patch)
tree4d4d86da08c5eb54ba2976d371a7da593311bafa /pysite/rst/__init__.py
parentFix test (diff)
Fix RST table styling and add fira-code text role
Diffstat (limited to 'pysite/rst/__init__.py')
-rw-r--r--pysite/rst/__init__.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pysite/rst/__init__.py b/pysite/rst/__init__.py
index 54dbba9c..e58fbe8c 100644
--- a/pysite/rst/__init__.py
+++ b/pysite/rst/__init__.py
@@ -5,7 +5,7 @@ from docutils.parsers.rst.directives import register_directive
from docutils.parsers.rst.roles import register_canonical_role
from pysite.rst.directives import ButtonDirective
-from pysite.rst.roles import icon_role, page_role, url_for_role
+from pysite.rst.roles import fira_code_role, icon_role, page_role, url_for_role
RST_TEMPLATE = """.. contents::
@@ -14,6 +14,8 @@ RST_TEMPLATE = """.. contents::
CONTENTS_REGEX = re.compile(r"""<div class=\"contents topic\" id=\"contents\">(.*?)</div>""", re.DOTALL)
HREF_REGEX = re.compile(r"""<a class=\"reference internal\" href=\"(.*?)\".*?>(.*?)</a>""")
+TABLE_FRAGMENT = """<table class="uk-table uk-table-divider table-bordered uk-table-striped">"""
+
def render(rst: str, link_headers=True):
if link_headers:
@@ -35,7 +37,6 @@ def render(rst: str, link_headers=True):
if match:
data["html"] = html.replace(match.group(0), "") # Remove the contents from the document HTML
-
depth = 0
headers = []
current_header = {}
@@ -93,9 +94,13 @@ def render(rst: str, link_headers=True):
current_header["sub_headers"] = sub_headers
data["headers"] = headers
+
+ data["html"] = data["html"].replace("<table>", TABLE_FRAGMENT) # Style the tables properly
+
return data
+register_canonical_role("fira_code", fira_code_role)
register_canonical_role("icon", icon_role)
register_canonical_role("page", page_role)
register_canonical_role("url_for", url_for_role)