""" Injects class into paragraph element. usage: add a list named "classes" to the desired Paragraph element content = my_parser.parse(my_md_text) for elem in content: if isinstance(elem, marko.block.Paragraph): elem.classes = ["my_custom_class", "my_other_class"] """ from marko.helpers import MarkoExtension class ClassInjectorRenderer: def render_paragraph(self, element) -> str: if not hasattr(element, "classes"): return super().render_paragraph(element) return f"

{self.render_children(element)}

" ClassInjector = MarkoExtension( renderer_mixins=[ClassInjectorRenderer] )