markdown-pdf 1.4__tar.gz → 1.5__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.4 → markdown_pdf-1.5}/PKG-INFO +21 -6
- {markdown_pdf-1.4 → markdown_pdf-1.5}/README.md +20 -5
- {markdown_pdf-1.4 → markdown_pdf-1.5}/markdown_pdf/__init__.py +9 -4
- {markdown_pdf-1.4 → markdown_pdf-1.5}/markdown_pdf.egg-info/PKG-INFO +21 -6
- {markdown_pdf-1.4 → markdown_pdf-1.5}/setup.cfg +1 -1
- {markdown_pdf-1.4 → markdown_pdf-1.5}/LICENSE +0 -0
- {markdown_pdf-1.4 → markdown_pdf-1.5}/MANIFEST.in +0 -0
- {markdown_pdf-1.4 → markdown_pdf-1.5}/markdown_pdf.egg-info/SOURCES.txt +0 -0
- {markdown_pdf-1.4 → markdown_pdf-1.5}/markdown_pdf.egg-info/dependency_links.txt +0 -0
- {markdown_pdf-1.4 → markdown_pdf-1.5}/markdown_pdf.egg-info/requires.txt +0 -0
- {markdown_pdf-1.4 → markdown_pdf-1.5}/markdown_pdf.egg-info/top_level.txt +0 -0
- {markdown_pdf-1.4 → markdown_pdf-1.5}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown_pdf
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5
|
|
4
4
|
Summary: Markdown to pdf renderer
|
|
5
5
|
Home-page: https://github.com/vb64/markdown-pdf
|
|
6
6
|
Author: Vitaly Bogomolov
|
|
@@ -26,6 +26,7 @@ Description: # Module markdown-pdf
|
|
|
26
26
|
- Tune the necessary elements using your CSS code
|
|
27
27
|
- Use different page sizes within single pdf
|
|
28
28
|
- Create tables in `markdown`
|
|
29
|
+
- Use clickable hyperlinks. Thanks a lot [@thongtmtrust](https://github.com/thongtmtrust) for ideas and collaboration.
|
|
29
30
|
|
|
30
31
|
The module utilizes the functions of two great libraries.
|
|
31
32
|
|
|
@@ -56,24 +57,38 @@ Description: # Module markdown-pdf
|
|
|
56
57
|
pdf.add_section(Section("# Title\n", toc=False))
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
Add a second section
|
|
60
|
+
Add a second section with external and internal hyperlinks.
|
|
61
|
+
In the pdf file it starts on a new page.
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
text = """# Section with links
|
|
65
|
+
|
|
66
|
+
- [External link](https://github.com/vb64/markdown-pdf)
|
|
67
|
+
- [Internal link to Head1](#head1)
|
|
68
|
+
- [Internal link to Head3](#head3)
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
pdf.add_section(Section(text))
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Add a third section.
|
|
60
75
|
The title is centered using CSS, included in the table of contents of the pdf file, and an image from the file `img/python.png` is embedded on the page.
|
|
61
76
|
|
|
62
77
|
```python
|
|
63
78
|
pdf.add_section(
|
|
64
|
-
Section("# Head1\n\n\n\nbody\n"),
|
|
79
|
+
Section("# <a name='head1'></a>Head1\n\n\n\nbody\n"),
|
|
65
80
|
user_css="h1 {text-align:center;}"
|
|
66
81
|
)
|
|
67
82
|
```
|
|
68
83
|
|
|
69
|
-
Add a
|
|
84
|
+
Add a next section. Two headings of different levels from this section are included in the TOC of the pdf file.
|
|
70
85
|
The section has landscape orientation of A4 pages.
|
|
71
86
|
|
|
72
87
|
```python
|
|
73
|
-
pdf.add_section(Section("## Head2\n\n### Head3\n\n", paper_size="A4-L"))
|
|
88
|
+
pdf.add_section(Section("## Head2\n\n### <a id='head3'></a>Head3\n\n", paper_size="A4-L"))
|
|
74
89
|
```
|
|
75
90
|
|
|
76
|
-
Add a
|
|
91
|
+
Add a section with a table.
|
|
77
92
|
|
|
78
93
|
```python
|
|
79
94
|
|
|
@@ -17,6 +17,7 @@ When creating a PDF file you can:
|
|
|
17
17
|
- Tune the necessary elements using your CSS code
|
|
18
18
|
- Use different page sizes within single pdf
|
|
19
19
|
- Create tables in `markdown`
|
|
20
|
+
- Use clickable hyperlinks. Thanks a lot [@thongtmtrust](https://github.com/thongtmtrust) for ideas and collaboration.
|
|
20
21
|
|
|
21
22
|
The module utilizes the functions of two great libraries.
|
|
22
23
|
|
|
@@ -47,24 +48,38 @@ from markdown_pdf import Section
|
|
|
47
48
|
pdf.add_section(Section("# Title\n", toc=False))
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
Add a second section
|
|
51
|
+
Add a second section with external and internal hyperlinks.
|
|
52
|
+
In the pdf file it starts on a new page.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
text = """# Section with links
|
|
56
|
+
|
|
57
|
+
- [External link](https://github.com/vb64/markdown-pdf)
|
|
58
|
+
- [Internal link to Head1](#head1)
|
|
59
|
+
- [Internal link to Head3](#head3)
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
pdf.add_section(Section(text))
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Add a third section.
|
|
51
66
|
The title is centered using CSS, included in the table of contents of the pdf file, and an image from the file `img/python.png` is embedded on the page.
|
|
52
67
|
|
|
53
68
|
```python
|
|
54
69
|
pdf.add_section(
|
|
55
|
-
Section("# Head1\n\n\n\nbody\n"),
|
|
70
|
+
Section("# <a name='head1'></a>Head1\n\n\n\nbody\n"),
|
|
56
71
|
user_css="h1 {text-align:center;}"
|
|
57
72
|
)
|
|
58
73
|
```
|
|
59
74
|
|
|
60
|
-
Add a
|
|
75
|
+
Add a next section. Two headings of different levels from this section are included in the TOC of the pdf file.
|
|
61
76
|
The section has landscape orientation of A4 pages.
|
|
62
77
|
|
|
63
78
|
```python
|
|
64
|
-
pdf.add_section(Section("## Head2\n\n### Head3\n\n", paper_size="A4-L"))
|
|
79
|
+
pdf.add_section(Section("## Head2\n\n### <a id='head3'></a>Head3\n\n", paper_size="A4-L"))
|
|
65
80
|
```
|
|
66
81
|
|
|
67
|
-
Add a
|
|
82
|
+
Add a section with a table.
|
|
68
83
|
|
|
69
84
|
```python
|
|
70
85
|
|
|
@@ -51,11 +51,15 @@ class MarkdownPdf:
|
|
|
51
51
|
|
|
52
52
|
self.out_file = io.BytesIO()
|
|
53
53
|
self.writer = fitz.DocumentWriter(self.out_file)
|
|
54
|
-
self.
|
|
54
|
+
self.page_num = 0
|
|
55
|
+
self.hrefs = []
|
|
55
56
|
|
|
56
57
|
@staticmethod
|
|
57
58
|
def _recorder(elpos):
|
|
58
59
|
"""Call function invoked during story.place() for making a TOC."""
|
|
60
|
+
elpos.page_num = elpos.pdfile.page_num
|
|
61
|
+
elpos.pdfile.hrefs.append(elpos)
|
|
62
|
+
|
|
59
63
|
if not elpos.open_close & 1: # only consider "open" items
|
|
60
64
|
return
|
|
61
65
|
if not elpos.toc:
|
|
@@ -65,7 +69,7 @@ class MarkdownPdf:
|
|
|
65
69
|
elpos.pdfile.toc.append((
|
|
66
70
|
elpos.heading,
|
|
67
71
|
elpos.text,
|
|
68
|
-
elpos.pdfile.
|
|
72
|
+
elpos.pdfile.page_num,
|
|
69
73
|
elpos.rect[1], # top of written rectangle (use for TOC)
|
|
70
74
|
))
|
|
71
75
|
|
|
@@ -77,7 +81,7 @@ class MarkdownPdf:
|
|
|
77
81
|
story = fitz.Story(html=html, archive=section.root, user_css=user_css)
|
|
78
82
|
more = 1
|
|
79
83
|
while more: # loop outputting the story
|
|
80
|
-
self.
|
|
84
|
+
self.page_num += 1
|
|
81
85
|
device = self.writer.begin_page(rect)
|
|
82
86
|
more, _ = story.place(where) # layout into allowed rectangle
|
|
83
87
|
story.element_positions(self._recorder, {"toc": section.toc, "pdfile": self})
|
|
@@ -89,7 +93,8 @@ class MarkdownPdf:
|
|
|
89
93
|
def save(self, file_name: typing.Union[str, pathlib.Path]) -> None:
|
|
90
94
|
"""Save pdf to file."""
|
|
91
95
|
self.writer.close()
|
|
92
|
-
|
|
96
|
+
self.out_file.seek(0)
|
|
97
|
+
doc = fitz.Story.add_pdf_links(self.out_file, self.hrefs)
|
|
93
98
|
doc.set_metadata(self.meta)
|
|
94
99
|
if self.toc_level > 0:
|
|
95
100
|
doc.set_toc(self.toc)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: markdown-pdf
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5
|
|
4
4
|
Summary: Markdown to pdf renderer
|
|
5
5
|
Home-page: https://github.com/vb64/markdown-pdf
|
|
6
6
|
Author: Vitaly Bogomolov
|
|
@@ -26,6 +26,7 @@ Description: # Module markdown-pdf
|
|
|
26
26
|
- Tune the necessary elements using your CSS code
|
|
27
27
|
- Use different page sizes within single pdf
|
|
28
28
|
- Create tables in `markdown`
|
|
29
|
+
- Use clickable hyperlinks. Thanks a lot [@thongtmtrust](https://github.com/thongtmtrust) for ideas and collaboration.
|
|
29
30
|
|
|
30
31
|
The module utilizes the functions of two great libraries.
|
|
31
32
|
|
|
@@ -56,24 +57,38 @@ Description: # Module markdown-pdf
|
|
|
56
57
|
pdf.add_section(Section("# Title\n", toc=False))
|
|
57
58
|
```
|
|
58
59
|
|
|
59
|
-
Add a second section
|
|
60
|
+
Add a second section with external and internal hyperlinks.
|
|
61
|
+
In the pdf file it starts on a new page.
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
text = """# Section with links
|
|
65
|
+
|
|
66
|
+
- [External link](https://github.com/vb64/markdown-pdf)
|
|
67
|
+
- [Internal link to Head1](#head1)
|
|
68
|
+
- [Internal link to Head3](#head3)
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
pdf.add_section(Section(text))
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Add a third section.
|
|
60
75
|
The title is centered using CSS, included in the table of contents of the pdf file, and an image from the file `img/python.png` is embedded on the page.
|
|
61
76
|
|
|
62
77
|
```python
|
|
63
78
|
pdf.add_section(
|
|
64
|
-
Section("# Head1\n\n\n\nbody\n"),
|
|
79
|
+
Section("# <a name='head1'></a>Head1\n\n\n\nbody\n"),
|
|
65
80
|
user_css="h1 {text-align:center;}"
|
|
66
81
|
)
|
|
67
82
|
```
|
|
68
83
|
|
|
69
|
-
Add a
|
|
84
|
+
Add a next section. Two headings of different levels from this section are included in the TOC of the pdf file.
|
|
70
85
|
The section has landscape orientation of A4 pages.
|
|
71
86
|
|
|
72
87
|
```python
|
|
73
|
-
pdf.add_section(Section("## Head2\n\n### Head3\n\n", paper_size="A4-L"))
|
|
88
|
+
pdf.add_section(Section("## Head2\n\n### <a id='head3'></a>Head3\n\n", paper_size="A4-L"))
|
|
74
89
|
```
|
|
75
90
|
|
|
76
|
-
Add a
|
|
91
|
+
Add a section with a table.
|
|
77
92
|
|
|
78
93
|
```python
|
|
79
94
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|