From 30a3008712d8d9044c6be478d17092c2d7ee7eb2 Mon Sep 17 00:00:00 2001 From: Vitaly Bogomolov Date: Wed, 8 Jan 2025 15:06:57 +0400 Subject: [PATCH] test latex css (#41) --- .flake8 | 2 ++ fixture/latex2.md | 5 +++++ tests/test/test_latex.py | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 fixture/latex2.md diff --git a/.flake8 b/.flake8 index dcc8dce..b826184 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,4 @@ [flake8] max_line_length = 120 +per-file-ignores = + tests/test/test_latex.py:E501 diff --git a/fixture/latex2.md b/fixture/latex2.md new file mode 100644 index 0000000..69e858e --- /dev/null +++ b/fixture/latex2.md @@ -0,0 +1,5 @@ +# Title + +test some math formula + +write some $$\sum_1^n x_n$$ diff --git a/tests/test/test_latex.py b/tests/test/test_latex.py index bcb282b..451d05d 100644 --- a/tests/test/test_latex.py +++ b/tests/test/test_latex.py @@ -2,8 +2,14 @@ make test T=test_latex.py """ +# pylint: disable=line-too-long from . import TestBase +LATEX_CSS = """ + + +""" + class TestLatex(TestBase): """Latex content.""" @@ -17,3 +23,14 @@ def test_latex(self): html = pdf.add_section(Section(text)) # print(html) assert "$$" in html + + def test_latex_css(self): + """Convert latext content to pdf with css.""" + from markdown_pdf import Section, MarkdownPdf + + pdf = MarkdownPdf() + pdf.add_section( + Section(open(self.fixture("latex2.md"), "rt", encoding='utf-8').read()), + user_css=LATEX_CSS + ) + pdf.save(self.build("latex2.pdf"))