markdown-pdf 1.12__tar.gz → 1.13__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.
- {markdown_pdf-1.12/markdown_pdf.egg-info → markdown_pdf-1.13}/PKG-INFO +12 -2
- {markdown_pdf-1.12 → markdown_pdf-1.13}/README.md +11 -1
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf/__init__.py +5 -1
- {markdown_pdf-1.12 → markdown_pdf-1.13/markdown_pdf.egg-info}/PKG-INFO +12 -2
- {markdown_pdf-1.12 → markdown_pdf-1.13}/pyproject.toml +1 -1
- {markdown_pdf-1.12 → markdown_pdf-1.13}/LICENSE +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/MANIFEST.in +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf/pligins/__init__.py +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf/pligins/helpers.py +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf/pligins/mermaid.py +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf/pligins/plantuml.py +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf/py.typed +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf.egg-info/SOURCES.txt +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf.egg-info/dependency_links.txt +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf.egg-info/requires.txt +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/markdown_pdf.egg-info/top_level.txt +0 -0
- {markdown_pdf-1.12 → markdown_pdf-1.13}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown_pdf
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.13
|
|
4
4
|
Summary: Markdown to pdf renderer
|
|
5
5
|
Author-email: Vitaly Bogomolov <mail@vitaly-bogomolov.ru>
|
|
6
6
|
License-Expression: AGPL-3.0-only
|
|
@@ -69,11 +69,15 @@ pdf = MarkdownPdf(toc_level=2, optimize=True)
|
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Add the first section to the pdf. The title is not included in the table of contents.
|
|
72
|
+
After adding a section to a pdf, the `page_count` property in the section contains the number of pdf pages created for the added section.
|
|
72
73
|
|
|
73
74
|
```python
|
|
74
75
|
from markdown_pdf import Section
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
section = Section("# Title\n", toc=False)
|
|
78
|
+
assert section.page_count == 0
|
|
79
|
+
pdf.add_section(section)
|
|
80
|
+
assert section.page_count == 1
|
|
77
81
|
```
|
|
78
82
|
|
|
79
83
|
Add a second section with external and internal hyperlinks.
|
|
@@ -124,6 +128,12 @@ css = "table, th, td {border: 1px solid black;}"
|
|
|
124
128
|
pdf.add_section(Section(text), user_css=css)
|
|
125
129
|
```
|
|
126
130
|
|
|
131
|
+
The `sections` property of the `MarkdownPdf` class contains a list of added sections in the order in which they were added.
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
assert len(pdf.sections) > 1
|
|
135
|
+
```
|
|
136
|
+
|
|
127
137
|
Set the properties of the pdf document.
|
|
128
138
|
|
|
129
139
|
```python
|
|
@@ -42,11 +42,15 @@ pdf = MarkdownPdf(toc_level=2, optimize=True)
|
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Add the first section to the pdf. The title is not included in the table of contents.
|
|
45
|
+
After adding a section to a pdf, the `page_count` property in the section contains the number of pdf pages created for the added section.
|
|
45
46
|
|
|
46
47
|
```python
|
|
47
48
|
from markdown_pdf import Section
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
section = Section("# Title\n", toc=False)
|
|
51
|
+
assert section.page_count == 0
|
|
52
|
+
pdf.add_section(section)
|
|
53
|
+
assert section.page_count == 1
|
|
50
54
|
```
|
|
51
55
|
|
|
52
56
|
Add a second section with external and internal hyperlinks.
|
|
@@ -97,6 +101,12 @@ css = "table, th, td {border: 1px solid black;}"
|
|
|
97
101
|
pdf.add_section(Section(text), user_css=css)
|
|
98
102
|
```
|
|
99
103
|
|
|
104
|
+
The `sections` property of the `MarkdownPdf` class contains a list of added sections in the order in which they were added.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
assert len(pdf.sections) > 1
|
|
108
|
+
```
|
|
109
|
+
|
|
100
110
|
Set the properties of the pdf document.
|
|
101
111
|
|
|
102
112
|
```python
|
|
@@ -28,6 +28,7 @@ class Section:
|
|
|
28
28
|
self.text = text
|
|
29
29
|
self.toc = toc
|
|
30
30
|
self.root = root
|
|
31
|
+
self.page_count = 0
|
|
31
32
|
|
|
32
33
|
self.paper_size = paper_size
|
|
33
34
|
if isinstance(paper_size, str):
|
|
@@ -75,11 +76,11 @@ class MarkdownPdf:
|
|
|
75
76
|
self.m_d = (MarkdownIt(mode).enable('table')) # Enable support for tables
|
|
76
77
|
|
|
77
78
|
self.optimize = optimize
|
|
78
|
-
|
|
79
79
|
self.out_file = io.BytesIO()
|
|
80
80
|
self.writer = fitz.DocumentWriter(self.out_file)
|
|
81
81
|
self.page_num = 0
|
|
82
82
|
self.hrefs = []
|
|
83
|
+
self.sections = []
|
|
83
84
|
|
|
84
85
|
@staticmethod
|
|
85
86
|
def _recorder(elpos):
|
|
@@ -120,12 +121,15 @@ class MarkdownPdf:
|
|
|
120
121
|
more = 1
|
|
121
122
|
while more: # loop outputting the story
|
|
122
123
|
self.page_num += 1
|
|
124
|
+
section.page_count += 1
|
|
123
125
|
device = self.writer.begin_page(section.rect)
|
|
124
126
|
more, _ = story.place(where) # layout into allowed rectangle
|
|
125
127
|
story.element_positions(self._recorder, {"toc": section.toc, "pdfile": self})
|
|
126
128
|
story.draw(device)
|
|
127
129
|
self.writer.end_page()
|
|
128
130
|
|
|
131
|
+
self.sections.append(section)
|
|
132
|
+
|
|
129
133
|
return html
|
|
130
134
|
|
|
131
135
|
def _make_doc(self):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown_pdf
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.13
|
|
4
4
|
Summary: Markdown to pdf renderer
|
|
5
5
|
Author-email: Vitaly Bogomolov <mail@vitaly-bogomolov.ru>
|
|
6
6
|
License-Expression: AGPL-3.0-only
|
|
@@ -69,11 +69,15 @@ pdf = MarkdownPdf(toc_level=2, optimize=True)
|
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Add the first section to the pdf. The title is not included in the table of contents.
|
|
72
|
+
After adding a section to a pdf, the `page_count` property in the section contains the number of pdf pages created for the added section.
|
|
72
73
|
|
|
73
74
|
```python
|
|
74
75
|
from markdown_pdf import Section
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
section = Section("# Title\n", toc=False)
|
|
78
|
+
assert section.page_count == 0
|
|
79
|
+
pdf.add_section(section)
|
|
80
|
+
assert section.page_count == 1
|
|
77
81
|
```
|
|
78
82
|
|
|
79
83
|
Add a second section with external and internal hyperlinks.
|
|
@@ -124,6 +128,12 @@ css = "table, th, td {border: 1px solid black;}"
|
|
|
124
128
|
pdf.add_section(Section(text), user_css=css)
|
|
125
129
|
```
|
|
126
130
|
|
|
131
|
+
The `sections` property of the `MarkdownPdf` class contains a list of added sections in the order in which they were added.
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
assert len(pdf.sections) > 1
|
|
135
|
+
```
|
|
136
|
+
|
|
127
137
|
Set the properties of the pdf document.
|
|
128
138
|
|
|
129
139
|
```python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|