Release v2.2.1: Validate pdf_path directory before importing optional reportlab/pypdf in compile_markdown_to_pdf and remove unused pdfplumber dependency
This commit is contained in:
1 parent
8ea64c11c1
commit
2a882853a9
39 files changed
+152
-149
No files matched your search
@@ -262,6 +262,11 @@ def compile_markdown_to_pdf(
|
||||
pdf_path: str | Path,
|
||||
title: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
md_p = Path(md_path).resolve()
|
||||
pdf_p = Path(pdf_path).resolve()
|
||||
pdf_p.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp_p = pdf_p.with_suffix(f".tmp.{os.getpid()}.pdf")
|
||||
|
||||
try:
|
||||
from pypdf import PdfReader
|
||||
from reportlab.lib import colors
|
||||
@@ -269,7 +274,7 @@ def compile_markdown_to_pdf(
|
||||
import subprocess
|
||||
import sys
|
||||
subprocess.run(
|
||||
[sys.executable, "-m", "pip", "install", "--break-system-packages", "--root-user-action=ignore", "-q", "reportlab", "pypdf"],
|
||||
[sys.executable, "-m", "pip", "install", "--break-system-packages", "--root-user-action=ignore", "--no-deps", "-q", "reportlab", "pypdf"],
|
||||
check=True,
|
||||
)
|
||||
from pypdf import PdfReader
|
||||
@@ -291,11 +296,6 @@ def compile_markdown_to_pdf(
|
||||
)
|
||||
from hyperstitionstud_io.publishing.fonts import resolve_font_path
|
||||
|
||||
md_p = Path(md_path).resolve()
|
||||
pdf_p = Path(pdf_path).resolve()
|
||||
pdf_p.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp_p = pdf_p.with_suffix(f".tmp.{os.getpid()}.pdf")
|
||||
|
||||
f_reg = resolve_font_path("DejaVuSans.ttf")
|
||||
f_bold = resolve_font_path("DejaVuSans-Bold.ttf")
|
||||
f_ob = resolve_font_path("DejaVuSans-Oblique.ttf", fallback_filename="DejaVuSans.ttf")
|
||||
|
||||
Reference in new issue
Block a user