Skip to content

Commit 67d3b0b

Browse files
committed
use extra-css instead of replacing the CSS file
1 parent efb27f9 commit 67d3b0b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

library/mediafiles/process_text.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@ def process_path(args, path) -> str | None:
279279
output_path.rmdir()
280280
return str(path)
281281

282-
# replace CSS
283-
base_folder = Path(__file__).resolve().parent
284-
shutil.copy((base_folder / ".." / "assets" / "calibre.css").resolve(), output_path / "stylesheet.css")
285-
286282
# shrink images
287283
image_paths = shell_utils.rglob(str(output_path), consts.IMAGE_EXTENSIONS, quiet=True)[0]
288284

@@ -312,15 +308,23 @@ def process_path(args, path) -> str | None:
312308
epub_path = output_path.with_suffix(".OEB.epub")
313309
epub_path = Path(devices.clobber_new_file(args, str(epub_path)))
314310

311+
# Use extra-css instead of replacing stylesheet.css
312+
base_folder = Path(__file__).resolve().parent
313+
css_path = str((base_folder / ".." / "assets" / "calibre.css").resolve())
314+
315315
epub_command = [
316316
"ebook-convert",
317317
str(opf_path),
318318
str(epub_path),
319319
"--no-default-epub-cover",
320320
"--epub-inline-toc",
321321
"--dont-split-on-page-breaks",
322+
"--epub-max-image-size=none",
323+
"--output-profile tablet",
322324
]
323325

326+
epub_command.append(f"--extra-css={css_path}")
327+
324328
if args.simulate:
325329
print(shlex.join(epub_command))
326330
return str(path)

0 commit comments

Comments
 (0)