1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
from markdown import markdown
html = markdown(
"""
# Top title (ATX)
Subtitle (setext)
-----------------
### An even lower heading (ATX)
**Text in bold**
_Text in italics_
[This is a link](https://github.com/PyFPDF/fpdf2)
<https://py-pdf.github.io/fpdf2/>
This is an unordered list:
* an item
* another item
This is an ordered list:
1. first item
2. second item
3. third item with an unordered sublist:
* an item
* another item
Inline `code span`
A table:
Foo | Bar | Baz
--- | --- | ---
Foo | Bar | Baz
Definition list:
Term
: Definition
Actual HTML:
<dl>
<dt>Term1</dt><dd>Definition1</dd>
<dt>Term2</dt><dd>Definition2</dd>
</dl>
Some horizontal thematic breaks:
***
---
___

""",
extensions=["def_list", "sane_lists", "tables"],
)
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.write_html(html)
pdf.output("pdf-from-markdown-with-markdown.pdf")
|