Skip to content

Commit

Permalink
fix img
Browse files Browse the repository at this point in the history
  • Loading branch information
vb64 committed Jun 11, 2024
1 parent baae158 commit a88878d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Binary file modified img/with_toc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 13 additions & 12 deletions tests/test/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"""
from . import TestBase

TABLE_TEXT = """# Section with Table
|TableHeader1|TableHeader2|
|--|--|
|Text1|Text2|
|ListCell|<ul><li>FirstBullet</li><li>SecondBullet</li></ul>|
"""


class TestConverter(TestBase):
"""Converter markdown_pdf."""
Expand All @@ -19,6 +27,7 @@ def test_with_toc(self):
user_css="h1 {text-align:center;}"
)
pdf.add_section(Section("## Head2\n\n### Head3\n\n"))
pdf.add_section(Section(TABLE_TEXT))
pdf.save(self.build("with_toc.pdf"))

def test_no_toc(self):
Expand All @@ -29,25 +38,17 @@ def test_no_toc(self):
pdf.add_section(Section("# Title\n"))
pdf.save(self.build("no_toc.pdf"))

def test_table_html(self):
"""Convert md table to html."""
def test_table(self):
"""Convert md table."""

# https://github.com/executablebooks/markdown-it-py?tab=readme-ov-file#python-api-usage
from markdown_it import MarkdownIt
from markdown_pdf import Section, MarkdownPdf

md = MarkdownIt('commonmark').enable('table')
text = ("""
# Section with Table
|TableHeader1|TableHeader2|
|--|--|
|Text1|Text2|
|ListCell|<ul><li>FirstBullet</li><li>SecondBullet</li></ul>|
""")
html_text = md.render(text)
html_text = md.render(TABLE_TEXT)
assert '<table>' in html_text

pdf = MarkdownPdf(toc_level=0)
pdf.add_section(Section(text))
pdf.add_section(Section(TABLE_TEXT))
pdf.save(self.build("table.pdf"))

0 comments on commit a88878d

Please sign in to comment.