markdown-pdf 1.3__tar.gz → 1.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown_pdf
3
- Version: 1.3
3
+ Version: 1.3.2
4
4
  Summary: Markdown to pdf renderer
5
5
  Home-page: https://github.com/vb64/markdown-pdf
6
6
  Author: Vitaly Bogomolov
@@ -18,7 +18,7 @@ Requires-Dist: markdown-it-py==3.0.0
18
18
  # Module markdown-pdf
19
19
 
20
20
  [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/pep257.yml?label=Pep257&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apep257)
21
- [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/py3.yml?label=Python%203.8-3.12&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apy3)
21
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/py3.yml?label=Python%203.8-3.13&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apy3)
22
22
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/27b53043bff34f07bfb79ee1672b7ba0)](https://app.codacy.com/gh/vb64/markdown-pdf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
23
23
  [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/27b53043bff34f07bfb79ee1672b7ba0)](https://app.codacy.com/gh/vb64/markdown-pdf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
24
24
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/markdown-pdf?label=pypi%20installs)](https://pypistats.org/packages/markdown-pdf)
@@ -93,7 +93,9 @@ text = """# Section with Table
93
93
  |ListCell|<ul><li>FirstBullet</li><li>SecondBullet</li></ul>|
94
94
  """
95
95
 
96
- pdf.add_section(Section(text))
96
+ css = "table, th, td {border: 1px solid black;}"
97
+
98
+ pdf.add_section(Section(text), user_css=css)
97
99
  ```
98
100
 
99
101
  Set the properties of the pdf document.
@@ -1,7 +1,7 @@
1
1
  # Module markdown-pdf
2
2
 
3
3
  [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/pep257.yml?label=Pep257&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apep257)
4
- [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/py3.yml?label=Python%203.8-3.12&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apy3)
4
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/py3.yml?label=Python%203.8-3.13&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apy3)
5
5
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/27b53043bff34f07bfb79ee1672b7ba0)](https://app.codacy.com/gh/vb64/markdown-pdf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
6
6
  [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/27b53043bff34f07bfb79ee1672b7ba0)](https://app.codacy.com/gh/vb64/markdown-pdf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
7
7
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/markdown-pdf?label=pypi%20installs)](https://pypistats.org/packages/markdown-pdf)
@@ -76,7 +76,9 @@ text = """# Section with Table
76
76
  |ListCell|<ul><li>FirstBullet</li><li>SecondBullet</li></ul>|
77
77
  """
78
78
 
79
- pdf.add_section(Section(text))
79
+ css = "table, th, td {border: 1px solid black;}"
80
+
81
+ pdf.add_section(Section(text), user_css=css)
80
82
  ```
81
83
 
82
84
  Set the properties of the pdf document.
@@ -1,5 +1,7 @@
1
1
  """Markdown to pdf converter based on markdown_it and fitz."""
2
2
  import io
3
+ import typing
4
+ import pathlib
3
5
  from markdown_it import MarkdownIt
4
6
  import fitz
5
7
 
@@ -7,7 +9,14 @@ import fitz
7
9
  class Section:
8
10
  """Markdown section."""
9
11
 
10
- def __init__(self, text, toc=True, root=".", paper_size="A4", borders=(36, 36, -36, -36)):
12
+ def __init__(
13
+ self,
14
+ text: str,
15
+ toc: bool = True,
16
+ root: str = ".",
17
+ paper_size: str = "A4",
18
+ borders: tuple = (36, 36, -36, -36)
19
+ ):
11
20
  """Create md section with given properties."""
12
21
  self.text = text
13
22
  self.toc = toc
@@ -31,7 +40,7 @@ class MarkdownPdf:
31
40
  "keywords": None,
32
41
  }
33
42
 
34
- def __init__(self, toc_level=6, mode='commonmark'):
43
+ def __init__(self, toc_level: int = 6, mode: str = 'commonmark'):
35
44
  """Create md -> pdf converter with given TOC level and mode of md parsing."""
36
45
  self.toc_level = toc_level
37
46
  self.toc = []
@@ -45,7 +54,7 @@ class MarkdownPdf:
45
54
  self.page = 0
46
55
 
47
56
  @staticmethod
48
- def recorder(elpos):
57
+ def _recorder(elpos):
49
58
  """Call function invoked during story.place() for making a TOC."""
50
59
  if not elpos.open_close & 1: # only consider "open" items
51
60
  return
@@ -60,7 +69,7 @@ class MarkdownPdf:
60
69
  elpos.rect[1], # top of written rectangle (use for TOC)
61
70
  ))
62
71
 
63
- def add_section(self, section, user_css=None):
72
+ def add_section(self, section: Section, user_css: typing.Optional[str] = None) -> None:
64
73
  """Add markdown section to pdf."""
65
74
  rect = fitz.paper_rect(section.paper_size)
66
75
  where = rect + section.borders
@@ -70,11 +79,11 @@ class MarkdownPdf:
70
79
  self.page += 1
71
80
  device = self.writer.begin_page(rect)
72
81
  more, _ = story.place(where) # layout into allowed rectangle
73
- story.element_positions(self.recorder, {"toc": section.toc, "pdfile": self})
82
+ story.element_positions(self._recorder, {"toc": section.toc, "pdfile": self})
74
83
  story.draw(device)
75
84
  self.writer.end_page()
76
85
 
77
- def save(self, file_name):
86
+ def save(self, file_name: typing.Union[str, pathlib.Path]) -> None:
78
87
  """Save pdf to file."""
79
88
  self.writer.close()
80
89
  doc = fitz.open("pdf", self.out_file)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown_pdf
3
- Version: 1.3
3
+ Version: 1.3.2
4
4
  Summary: Markdown to pdf renderer
5
5
  Home-page: https://github.com/vb64/markdown-pdf
6
6
  Author: Vitaly Bogomolov
@@ -18,7 +18,7 @@ Requires-Dist: markdown-it-py==3.0.0
18
18
  # Module markdown-pdf
19
19
 
20
20
  [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/pep257.yml?label=Pep257&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apep257)
21
- [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/py3.yml?label=Python%203.8-3.12&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apy3)
21
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vb64/markdown-pdf/py3.yml?label=Python%203.8-3.13&style=plastic&branch=main)](https://github.com/vb64/markdown-pdf/actions?query=workflow%3Apy3)
22
22
  [![Codacy Badge](https://app.codacy.com/project/badge/Grade/27b53043bff34f07bfb79ee1672b7ba0)](https://app.codacy.com/gh/vb64/markdown-pdf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
23
23
  [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/27b53043bff34f07bfb79ee1672b7ba0)](https://app.codacy.com/gh/vb64/markdown-pdf/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
24
24
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/markdown-pdf?label=pypi%20installs)](https://pypistats.org/packages/markdown-pdf)
@@ -93,7 +93,9 @@ text = """# Section with Table
93
93
  |ListCell|<ul><li>FirstBullet</li><li>SecondBullet</li></ul>|
94
94
  """
95
95
 
96
- pdf.add_section(Section(text))
96
+ css = "table, th, td {border: 1px solid black;}"
97
+
98
+ pdf.add_section(Section(text), user_css=css)
97
99
  ```
98
100
 
99
101
  Set the properties of the pdf document.
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = markdown_pdf
3
- version = 1.3
3
+ version = 1.3.2
4
4
  author = Vitaly Bogomolov
5
5
  author_email = mail@vitaly-bogomolov.ru
6
6
  description = Markdown to pdf renderer
File without changes
File without changes
File without changes