From f53767384aadf53448163edfd7445af851a0d4cd Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Mon, 8 Jul 2024 14:01:37 -0400 Subject: [PATCH 1/2] Workaround for RelaxedJS '--build-once' not working --- mkdocs_with_pdf/drivers/relaxedjs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkdocs_with_pdf/drivers/relaxedjs.py b/mkdocs_with_pdf/drivers/relaxedjs.py index a0177ad2..dbe0a584 100644 --- a/mkdocs_with_pdf/drivers/relaxedjs.py +++ b/mkdocs_with_pdf/drivers/relaxedjs.py @@ -42,3 +42,7 @@ def write_pdf(self, html_string: str, output: str): self._logger.info(f" {log}") if proc.poll() is not None: break + # workaround for '--build-once' not working + if log.find("Now idle and waiting for file changes") > -1: + proc.kill() + break From c0d78cb9a32c4f152ecbaa61b82b43d7b78fcca4 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Tue, 6 Aug 2024 15:00:54 -0400 Subject: [PATCH 2/2] Fix to fix_image_alignment failing to detect an image's style attribute. --- mkdocs_with_pdf/utils/image_util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mkdocs_with_pdf/utils/image_util.py b/mkdocs_with_pdf/utils/image_util.py index 3e73506d..21d69b4d 100644 --- a/mkdocs_with_pdf/utils/image_util.py +++ b/mkdocs_with_pdf/utils/image_util.py @@ -15,7 +15,12 @@ def fix_image_alignment(soup: PageElement, logger: Logger = None): if img.has_attr('class') and 'twemoji' in img['class']: continue - styles = _parse_style(getattr(img, 'style', '')) + if not (img.has_attr('align') + or img.has_attr('width') + or img.has_attr('height')): + continue + + styles = _parse_style(img.get('style', '')) logger.debug(f' | {img}') if img.has_attr('align'):