From 3295abdee147801c86b56ec77643dcc416f8ed3e Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Sun, 14 Jul 2024 23:36:20 +0200 Subject: heading injector module --- headinginjector.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 headinginjector.py (limited to 'headinginjector.py') diff --git a/headinginjector.py b/headinginjector.py new file mode 100644 index 0000000..50ef606 --- /dev/null +++ b/headinginjector.py @@ -0,0 +1,18 @@ +import marko.block +from marko.helpers import MarkoExtension + + +def __create_heading_renderer(prefix: str): + class HeadingRenderer: + PREFIX = prefix + + def render_heading(self, element: marko.block.Heading): + return f"{HeadingRenderer.PREFIX}{self.render_children(element)}\n" + + return HeadingRenderer + + +def get_heading_injector(prefix: str): + return MarkoExtension( + renderer_mixins=[__create_heading_renderer(prefix)] + ) -- cgit v1.2.3-70-g09d2