Closed SNeugber closed 4 months ago
You need to enable the fenced_code extension.
markdown.markdown(some_text, extensions=['fenced_code'])
Oooh, I was not aware, my bad. Thanks for clarifying, it works now :+1:
Thanks for the solution @waylan! Was able to get my template working like so:
#!/usr/bin/env python
import markdown
msg = """
# Hello, world!
This is a **test email** from [Resend](https://resend.com).
\```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
./send_email.py
\```
""".lstrip()
html = markdown.markdown(msg, extensions=["fenced_code"])
print(html)
(Ignore the escaped code block in nested markdown. Probably a better way to do it on GitHub, but don't have the bandwidth to find out)
I found a behaviour I wasn't expecting: when fenced code blocks contain newlines they are split up into individual
<p>
paragraphs, instead of one big<code>
block.Would you be able to clarify if this is a bug or not?
Sample code to reproduce: