markdown_convert 1.2.15__py3-none-any.whl → 1.2.17__py3-none-any.whl
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_convert/__main__.py +95 -96
- markdown_convert/code.css +73 -73
- markdown_convert/default.css +378 -372
- markdown_convert/modules/__init__.py +4 -4
- markdown_convert/modules/constants.py +23 -26
- markdown_convert/modules/convert.py +251 -247
- markdown_convert/modules/resources.py +98 -92
- markdown_convert/modules/utils.py +38 -38
- markdown_convert/modules/validate.py +61 -61
- {markdown_convert-1.2.15.dist-info → markdown_convert-1.2.17.dist-info}/METADATA +6 -7
- markdown_convert-1.2.17.dist-info/RECORD +14 -0
- {markdown_convert-1.2.15.dist-info → markdown_convert-1.2.17.dist-info}/WHEEL +1 -1
- {markdown_convert-1.2.15.dist-info → markdown_convert-1.2.17.dist-info}/licenses/LICENSE +339 -339
- markdown_convert-1.2.15.dist-info/RECORD +0 -14
- {markdown_convert-1.2.15.dist-info → markdown_convert-1.2.17.dist-info}/entry_points.txt +0 -0
|
@@ -1,92 +1,98 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module contains functions that are used to get the output path, the CSS
|
|
3
|
-
path, and the usage message.
|
|
4
|
-
Author: @julynx
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
|
-
try:
|
|
10
|
-
# Python 3.9+
|
|
11
|
-
from importlib.resources import files
|
|
12
|
-
except ImportError:
|
|
13
|
-
# Fallback for older Python versions
|
|
14
|
-
from importlib_resources import files
|
|
15
|
-
|
|
16
|
-
from .constants import BLUE, CYAN, GREEN, YELLOW, OPTIONS, OPTIONS_MODES
|
|
17
|
-
from .utils import color
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def get_output_path(md_path, output_dir=None):
|
|
21
|
-
"""
|
|
22
|
-
Get the output path for the pdf file.
|
|
23
|
-
|
|
24
|
-
Args:
|
|
25
|
-
md_path (str): The path to the markdown file.
|
|
26
|
-
output_dir (str): The output directory.
|
|
27
|
-
|
|
28
|
-
Returns:
|
|
29
|
-
str: The output path.
|
|
30
|
-
"""
|
|
31
|
-
md_path = Path(md_path)
|
|
32
|
-
|
|
33
|
-
if output_dir is None:
|
|
34
|
-
return md_path.parent / f"{md_path.stem}.pdf"
|
|
35
|
-
|
|
36
|
-
output_dir = Path(output_dir)
|
|
37
|
-
|
|
38
|
-
if output_dir.suffix == ".pdf":
|
|
39
|
-
return output_dir
|
|
40
|
-
|
|
41
|
-
return output_dir.parent / f"{Path(md_path).stem}.pdf"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def get_css_path():
|
|
45
|
-
"""
|
|
46
|
-
Get the path to the default CSS file.
|
|
47
|
-
|
|
48
|
-
Returns:
|
|
49
|
-
str: The path to the default CSS file.
|
|
50
|
-
"""
|
|
51
|
-
package_files = files(
|
|
52
|
-
css_file = package_files /
|
|
53
|
-
return str(css_file)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def get_code_css_path():
|
|
57
|
-
"""
|
|
58
|
-
Get the path to the code CSS file.
|
|
59
|
-
|
|
60
|
-
Returns:
|
|
61
|
-
str: The path to the code CSS file.
|
|
62
|
-
"""
|
|
63
|
-
package_files = files(
|
|
64
|
-
css_file = package_files /
|
|
65
|
-
return str(css_file)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def get_usage():
|
|
69
|
-
"""
|
|
70
|
-
Returns a message describing how to use the program.
|
|
71
|
-
|
|
72
|
-
Returns:
|
|
73
|
-
str: The usage message.
|
|
74
|
-
"""
|
|
75
|
-
commd = (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
"""
|
|
2
|
+
This module contains functions that are used to get the output path, the CSS
|
|
3
|
+
path, and the usage message.
|
|
4
|
+
Author: @julynx
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
# Python 3.9+
|
|
11
|
+
from importlib.resources import files
|
|
12
|
+
except ImportError:
|
|
13
|
+
# Fallback for older Python versions
|
|
14
|
+
from importlib_resources import files
|
|
15
|
+
|
|
16
|
+
from .constants import BLUE, CYAN, GREEN, YELLOW, OPTIONS, OPTIONS_MODES
|
|
17
|
+
from .utils import color
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_output_path(md_path, output_dir=None):
|
|
21
|
+
"""
|
|
22
|
+
Get the output path for the pdf file.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
md_path (str): The path to the markdown file.
|
|
26
|
+
output_dir (str): The output directory.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
str: The output path.
|
|
30
|
+
"""
|
|
31
|
+
md_path = Path(md_path)
|
|
32
|
+
|
|
33
|
+
if output_dir is None:
|
|
34
|
+
return md_path.parent / f"{md_path.stem}.pdf"
|
|
35
|
+
|
|
36
|
+
output_dir = Path(output_dir)
|
|
37
|
+
|
|
38
|
+
if output_dir.suffix == ".pdf":
|
|
39
|
+
return output_dir
|
|
40
|
+
|
|
41
|
+
return output_dir.parent / f"{Path(md_path).stem}.pdf"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get_css_path():
|
|
45
|
+
"""
|
|
46
|
+
Get the path to the default CSS file.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
str: The path to the default CSS file.
|
|
50
|
+
"""
|
|
51
|
+
package_files = files("markdown_convert")
|
|
52
|
+
css_file = package_files / "default.css"
|
|
53
|
+
return str(css_file)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def get_code_css_path():
|
|
57
|
+
"""
|
|
58
|
+
Get the path to the code CSS file.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
str: The path to the code CSS file.
|
|
62
|
+
"""
|
|
63
|
+
package_files = files("markdown_convert")
|
|
64
|
+
css_file = package_files / "code.css"
|
|
65
|
+
return str(css_file)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def get_usage():
|
|
69
|
+
"""
|
|
70
|
+
Returns a message describing how to use the program.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
str: The usage message.
|
|
74
|
+
"""
|
|
75
|
+
commd = (
|
|
76
|
+
f"{color(GREEN, 'markdown-convert')} "
|
|
77
|
+
f"[{color(YELLOW, OPTIONS[0])}] [{color(BLUE, 'options')}]"
|
|
78
|
+
)
|
|
79
|
+
opt_1 = f"{color(BLUE, OPTIONS[1])}{color(CYAN, '=')}{color(CYAN, '|'.join(OPTIONS_MODES))}"
|
|
80
|
+
opt_2 = (
|
|
81
|
+
f"{color(BLUE, OPTIONS[2])}{color(CYAN, '=')}[{color(CYAN, 'css_file_path')}]"
|
|
82
|
+
)
|
|
83
|
+
opt_3 = f"{color(BLUE, OPTIONS[3])}{color(CYAN, '=')}[{color(CYAN, 'output_file_path')}]"
|
|
84
|
+
|
|
85
|
+
usage = (
|
|
86
|
+
"\n"
|
|
87
|
+
"Usage:\n"
|
|
88
|
+
f" {commd}\n"
|
|
89
|
+
"\n"
|
|
90
|
+
"Options:\n"
|
|
91
|
+
f" {opt_1}\n"
|
|
92
|
+
" Convert the markdown file once (default) or live.\n"
|
|
93
|
+
f" {opt_2}\n"
|
|
94
|
+
" Use a custom CSS file.\n"
|
|
95
|
+
f" {opt_3}\n"
|
|
96
|
+
" Specify the output file path.\n"
|
|
97
|
+
)
|
|
98
|
+
return usage
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Utility functions for string manipulation.
|
|
3
|
-
Author: @julynx
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import platform
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def color(color_code, text):
|
|
10
|
-
"""
|
|
11
|
-
Colorize text.
|
|
12
|
-
|
|
13
|
-
Args:
|
|
14
|
-
text (str): The text to colorize.
|
|
15
|
-
color (str): The color code.
|
|
16
|
-
|
|
17
|
-
Returns:
|
|
18
|
-
str: The colorized text.
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
# Disable if running on Windows
|
|
22
|
-
if platform.system() == "Windows":
|
|
23
|
-
return text
|
|
24
|
-
|
|
25
|
-
return f"\033[{color_code}m{text}\033[0m"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def drop_duplicates(lst):
|
|
29
|
-
"""
|
|
30
|
-
Drops duplicates from the given list.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
lst: List to remove duplicates from.
|
|
34
|
-
|
|
35
|
-
Returns:
|
|
36
|
-
List without duplicates.
|
|
37
|
-
"""
|
|
38
|
-
return list(dict.fromkeys(lst))
|
|
1
|
+
"""
|
|
2
|
+
Utility functions for string manipulation.
|
|
3
|
+
Author: @julynx
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import platform
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def color(color_code, text):
|
|
10
|
+
"""
|
|
11
|
+
Colorize text.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
text (str): The text to colorize.
|
|
15
|
+
color (str): The color code.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
str: The colorized text.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
# Disable if running on Windows
|
|
22
|
+
if platform.system() == "Windows":
|
|
23
|
+
return text
|
|
24
|
+
|
|
25
|
+
return f"\033[{color_code}m{text}\033[0m"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def drop_duplicates(lst):
|
|
29
|
+
"""
|
|
30
|
+
Drops duplicates from the given list.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
lst: List to remove duplicates from.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
List without duplicates.
|
|
37
|
+
"""
|
|
38
|
+
return list(dict.fromkeys(lst))
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
"""
|
|
2
|
-
This module contains functions to validate the input paths.
|
|
3
|
-
Author: @julynx
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def validate_markdown_path(md_path):
|
|
10
|
-
"""
|
|
11
|
-
Validate the markdown file path.
|
|
12
|
-
|
|
13
|
-
Args:
|
|
14
|
-
md_path (str): The path to the markdown file.
|
|
15
|
-
|
|
16
|
-
Raises:
|
|
17
|
-
FileNotFoundError: If the file is not found.
|
|
18
|
-
ValueError: If the file is not a Markdown file.
|
|
19
|
-
"""
|
|
20
|
-
if not Path(md_path).is_file():
|
|
21
|
-
raise FileNotFoundError(f"File not found: '{md_path}'")
|
|
22
|
-
|
|
23
|
-
if not md_path.endswith(".md"):
|
|
24
|
-
raise ValueError("File must be a Markdown file.")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def validate_css_path(css_path):
|
|
28
|
-
"""
|
|
29
|
-
Validate the CSS file path.
|
|
30
|
-
|
|
31
|
-
Args:
|
|
32
|
-
css_path (str): The path to the CSS file.
|
|
33
|
-
|
|
34
|
-
Raises:
|
|
35
|
-
FileNotFoundError: If the file is not found.
|
|
36
|
-
ValueError: If the file is not a CSS file.
|
|
37
|
-
"""
|
|
38
|
-
if not Path(css_path).is_file():
|
|
39
|
-
raise FileNotFoundError(f"File not found: '{css_path}'")
|
|
40
|
-
|
|
41
|
-
if not css_path.endswith(".css"):
|
|
42
|
-
raise ValueError("File must be a CSS file.")
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def validate_output_path(output_dir):
|
|
46
|
-
"""
|
|
47
|
-
Validate the output directory path.
|
|
48
|
-
|
|
49
|
-
Args:
|
|
50
|
-
output_dir (str): The path to the output directory.
|
|
51
|
-
|
|
52
|
-
Raises:
|
|
53
|
-
FileNotFoundError: If the directory is not found.
|
|
54
|
-
"""
|
|
55
|
-
check_dir = Path(output_dir)
|
|
56
|
-
|
|
57
|
-
if output_dir.endswith(".pdf"):
|
|
58
|
-
check_dir = check_dir.parent
|
|
59
|
-
|
|
60
|
-
if not check_dir.is_dir():
|
|
61
|
-
raise FileNotFoundError(f"Directory not found: '{check_dir}'")
|
|
1
|
+
"""
|
|
2
|
+
This module contains functions to validate the input paths.
|
|
3
|
+
Author: @julynx
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def validate_markdown_path(md_path):
|
|
10
|
+
"""
|
|
11
|
+
Validate the markdown file path.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
md_path (str): The path to the markdown file.
|
|
15
|
+
|
|
16
|
+
Raises:
|
|
17
|
+
FileNotFoundError: If the file is not found.
|
|
18
|
+
ValueError: If the file is not a Markdown file.
|
|
19
|
+
"""
|
|
20
|
+
if not Path(md_path).is_file():
|
|
21
|
+
raise FileNotFoundError(f"File not found: '{md_path}'")
|
|
22
|
+
|
|
23
|
+
if not md_path.endswith(".md"):
|
|
24
|
+
raise ValueError("File must be a Markdown file.")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def validate_css_path(css_path):
|
|
28
|
+
"""
|
|
29
|
+
Validate the CSS file path.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
css_path (str): The path to the CSS file.
|
|
33
|
+
|
|
34
|
+
Raises:
|
|
35
|
+
FileNotFoundError: If the file is not found.
|
|
36
|
+
ValueError: If the file is not a CSS file.
|
|
37
|
+
"""
|
|
38
|
+
if not Path(css_path).is_file():
|
|
39
|
+
raise FileNotFoundError(f"File not found: '{css_path}'")
|
|
40
|
+
|
|
41
|
+
if not css_path.endswith(".css"):
|
|
42
|
+
raise ValueError("File must be a CSS file.")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def validate_output_path(output_dir):
|
|
46
|
+
"""
|
|
47
|
+
Validate the output directory path.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
output_dir (str): The path to the output directory.
|
|
51
|
+
|
|
52
|
+
Raises:
|
|
53
|
+
FileNotFoundError: If the directory is not found.
|
|
54
|
+
"""
|
|
55
|
+
check_dir = Path(output_dir)
|
|
56
|
+
|
|
57
|
+
if output_dir.endswith(".pdf"):
|
|
58
|
+
check_dir = check_dir.parent
|
|
59
|
+
|
|
60
|
+
if not check_dir.is_dir():
|
|
61
|
+
raise FileNotFoundError(f"Directory not found: '{check_dir}'")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown_convert
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.17
|
|
4
4
|
Summary: Convert Markdown files to PDF from your command line.
|
|
5
5
|
Project-URL: homepage, https://github.com/Julynx/markdown_convert
|
|
6
6
|
Author-email: Julio Cabria <juliocabria@tutanota.com>
|
|
@@ -9,11 +9,12 @@ License-File: LICENSE
|
|
|
9
9
|
Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Requires-Python: <
|
|
12
|
+
Requires-Python: <3.14,>=3.9
|
|
13
13
|
Requires-Dist: argsdict==1.0.0
|
|
14
|
+
Requires-Dist: latex2mathml>=3.78.1
|
|
14
15
|
Requires-Dist: markdown2<3,>=2.4.13
|
|
16
|
+
Requires-Dist: playwright>=1.57.0
|
|
15
17
|
Requires-Dist: pygments<3,>=2.17.2
|
|
16
|
-
Requires-Dist: weasyprint<70.0,>=62.3
|
|
17
18
|
Description-Content-Type: text/markdown
|
|
18
19
|
|
|
19
20
|
# markdown-convert
|
|
@@ -31,11 +32,9 @@ _Convert Markdown files to PDF from your command line._
|
|
|
31
32
|
|
|
32
33
|
<img src='https://i.imgur.com/SZIz2gY.png' width='80%'>
|
|
33
34
|
|
|
34
|
-
`markdown-convert` is an elegant command-line tool that converts Markdown files to PDF, powered by the amazing `markdown2` and `
|
|
35
|
+
`markdown-convert` is an elegant command-line tool that converts Markdown files to PDF, powered by the amazing `markdown2` and `playwright` libraries.
|
|
35
36
|
|
|
36
|
-
Unlike other similar tools, it relies solely on Python packages to do the job, eliminating the need for any external system-level dependencies
|
|
37
|
-
|
|
38
|
-
If you're running Windows, you only need to install the GTK-3 runtime from the following link: [GTK-3 Runtime](https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases).
|
|
37
|
+
Unlike other similar tools, it relies solely on Python packages to do the job, eliminating the need for any external system-level dependencies.
|
|
39
38
|
|
|
40
39
|
### Features
|
|
41
40
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
markdown_convert/__main__.py,sha256=zKgFcnxlXTRsR6AYhTdGEvQea2TVyLYeIxJSMksCMR0,2767
|
|
2
|
+
markdown_convert/code.css,sha256=Wt4FqFqJcpT-jwY3GN-o4ZRCCXU8DQj-9lqKdGiuoyw,4935
|
|
3
|
+
markdown_convert/default.css,sha256=BNAwHnnZzH8m9VinbL8T-C8GGpJj4cTIAFbUss-PzUg,8775
|
|
4
|
+
markdown_convert/modules/__init__.py,sha256=PFPgiQhMXgyfjD8BkfLC_X8AR1jz-dCxfif2qmNofJs,65
|
|
5
|
+
markdown_convert/modules/constants.py,sha256=rBRrz0Ctc46o4aKO7eERGyacsdJ4a-CXCUCEhYaQi2Q,448
|
|
6
|
+
markdown_convert/modules/convert.py,sha256=2jzc2nwM9-qFuwHzdyU292cFl3rORvGtcqcJh7UXCQg,7120
|
|
7
|
+
markdown_convert/modules/resources.py,sha256=aMDbM7Oab8A3nRN1tc1uNkmz8JfUdLJR6rF3ZR0IElo,2384
|
|
8
|
+
markdown_convert/modules/utils.py,sha256=NX0WegM8e8MPKNNmweTujAWO8ZghdB8LSGDx20K2E44,655
|
|
9
|
+
markdown_convert/modules/validate.py,sha256=cerfQ5Qt8gBQbh-NZ57zLmDfg-Vnyo0zsEFb8RUzVCQ,1487
|
|
10
|
+
markdown_convert-1.2.17.dist-info/METADATA,sha256=rsJKjyzaXixUixmXQjN18mz8k0bAVn9vaLGuJ_I7glI,2935
|
|
11
|
+
markdown_convert-1.2.17.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
12
|
+
markdown_convert-1.2.17.dist-info/entry_points.txt,sha256=RCmzC7C0sX-SpzIP2Cr34rhg3lMd7BRx-exaZPfK8bU,68
|
|
13
|
+
markdown_convert-1.2.17.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
|
14
|
+
markdown_convert-1.2.17.dist-info/RECORD,,
|