Skip to content

Commit

Permalink
test latex css (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
vb64 authored Jan 8, 2025
1 parent e6d0b38 commit 30a3008
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
max_line_length = 120
per-file-ignores =
tests/test/test_latex.py:E501
5 changes: 5 additions & 0 deletions fixture/latex2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Title

test some math formula

write some $$\sum_1^n x_n$$
17 changes: 17 additions & 0 deletions tests/test/test_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
make test T=test_latex.py
"""
# pylint: disable=line-too-long
from . import TestBase

LATEX_CSS = """
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });</script>
"""


class TestLatex(TestBase):
"""Latex content."""
Expand All @@ -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"))

0 comments on commit 30a3008

Please sign in to comment.