We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9f642d0 commit ca5e112Copy full SHA for ca5e112
1 file changed
docs/using.md
@@ -397,3 +397,29 @@ md = MarkdownIt("commonmark")
397
md.add_render_rule("link_open", render_blank_link)
398
print(md.render("[a]\n\n[a]: b"))
399
```
400
+
401
+### Markdown renderer
402
403
+You can also render a token stream directly to markdown via the `MDRenderer` class from [`mdformat`](https://github.com/executablebooks/mdformat):
404
405
+```{code-cell} python
406
+from markdown_it import MarkdownIt
407
+from mdformat.renderer import MDRenderer
408
409
+md = MarkdownIt("commonmark")
410
411
+source_markdown = """
412
+Here's some *text*
413
414
+1. a list
415
416
+> a *quote*"""
417
418
+tokens = md.parse(source_markdown)
419
420
+renderer = MDRenderer()
421
+options = {}
422
+env = {}
423
424
+output_markdown = renderer.render(tokens, options, env)
425
+```
0 commit comments