aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/rst/__init__.py
blob: 815ad05857e3f48678f122a9b0e286a3fbdad579 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# coding=utf-8
from docutils.core import publish_parts
from docutils.parsers.rst.roles import register_canonical_role

from pysite.rst.roles import icon_role, url_for_role


def render(rst: str):
    return publish_parts(
        source=rst, writer_name="html5", settings_overrides={"halt_level": 2, "syntax_highlight": "short"}
    )["html_body"]


register_canonical_role("icon", icon_role)
register_canonical_role("url_for", url_for_role)