diff --git a/pretext/__init__.py b/pretext/__init__.py index fa235a39..1254a9e7 100644 --- a/pretext/__init__.py +++ b/pretext/__init__.py @@ -21,7 +21,7 @@ VERSION = get_version("pretext", Path(__file__).parent.parent) -CORE_COMMIT = "8e9aac01da8fdab44c6c9ded4f30d9d7227d015b" +CORE_COMMIT = "ed4e9d94a75b5b728aca2eb06dfde3f1595ab783" def activate() -> None: diff --git a/pretext/constants.py b/pretext/constants.py index d34097c3..f8fba784 100644 --- a/pretext/constants.py +++ b/pretext/constants.py @@ -23,6 +23,7 @@ "codelens", "datafile", "interactive", + "mermaid", ], "latex": [ "webwork", @@ -32,6 +33,7 @@ "codelens", "datafile", "interactive", + "mermaid", ], "epub": [ "webwork", @@ -42,6 +44,7 @@ "codelens", "datafile", "interactive", + "mermaid", ], "kindle": [ "webwork", @@ -52,6 +55,7 @@ "codelens", "datafile", "interactive", + "mermaid", ], "braille": [ "webwork", @@ -62,6 +66,7 @@ "codelens", "datafile", "interactive", + "mermaid", ], "webwork": [ "webwork", @@ -75,6 +80,7 @@ "codelens", "datafile", "interactive", + "mermaid", ], } @@ -87,6 +93,7 @@ "codelens": ".//program[@interactive = 'codelens']", "datafile": ".//datafile", "interactive": ".//interactive", + "mermaid": ".//mermaid", } ASSETS = ["ALL"] + list(ASSET_TO_XPATH.keys()) @@ -99,6 +106,7 @@ "interactive": ["preview", "qrcode"], "codelens": ["trace"], "datafile": ["datafile"], + "mermaid": ["mermaid"], } ASSET_FORMATS: t.Dict[str, t.Dict[str, t.List[str]]] = { @@ -106,11 +114,13 @@ "asymptote": ["pdf"], "latex-image": [], "sageplot": ["pdf", "png"], + "mermaid": ["png"], }, "latex": { "asymptote": ["pdf"], "latex-image": [], "sageplot": ["pdf", "png"], + "mermaid": ["png"], }, "html": { "asymptote": ["html"], @@ -126,21 +136,25 @@ "asymptote": ["svg"], "latex-image": ["svg"], "sageplot": ["svg"], + "mermaid": ["png"], }, "kindle": { "asymptote": ["png"], "latex-image": ["png"], "sageplot": ["png"], + "mermaid": ["png"], }, "braille": { "asymptote": ["all"], "latex-image": ["all"], "sageplot": ["all"], + "mermaid": ["png"], }, "custom": { "asymptote": ["all"], "latex-image": ["all"], "sageplot": ["all"], + "mermaid": ["png"], }, } diff --git a/pretext/project/__init__.py b/pretext/project/__init__.py index ca93cbe7..42422130 100644 --- a/pretext/project/__init__.py +++ b/pretext/project/__init__.py @@ -927,6 +927,20 @@ def generate_assets( log.debug(e, exc_info=True) # youtube also requires the play button. self.ensure_play_button() + if "mermaid" in assets_to_generate: + for id in assets_to_generate["mermaid"]: + try: + core.mermaid_images( + xml_source=self.source_abspath(), + pub_file=self.publication_abspath().as_posix(), + stringparams=stringparams_copy, + xmlid_root=id, + dest_dir=self.generated_dir_abspath() / "mermaid", + ) + successful_assets.append(("mermaid", id)) + except Exception as e: + log.error(f"Unable to generate some mermaid images: \n{e}") + log.debug(e, exc_info=True) if "codelens" in assets_to_generate: for id in assets_to_generate["codelens"]: try: diff --git a/pretext/project/xml.py b/pretext/project/xml.py index e6cf129b..43315c3f 100644 --- a/pretext/project/xml.py +++ b/pretext/project/xml.py @@ -18,6 +18,7 @@ class Executables(pxml.BaseXmlModel, tag="executables"): asy: t.Optional[str] = pxml.attr(default=shutil.which("asy")) # The same applies to Sage. sage: t.Optional[str] = pxml.attr(default=shutil.which("sage")) + mermaid: str = pxml.attr(default="mmdc") pdfpng: str = pxml.attr(default="convert") pdfeps: str = pxml.attr(default="pdftops") node: str = pxml.attr(default="node")