From e91ef91963f58cc5d909ec89c46171a6a7756101 Mon Sep 17 00:00:00 2001 From: Michele Tessaro Date: Sat, 3 Aug 2024 15:26:09 +0200 Subject: [PATCH 1/3] fix: usr: fixed plantuml config file path with local rendering (fixes #101) --- plantuml_markdown/plantuml_markdown.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plantuml_markdown/plantuml_markdown.py b/plantuml_markdown/plantuml_markdown.py index 12a13ef..468f680 100644 --- a/plantuml_markdown/plantuml_markdown.py +++ b/plantuml_markdown/plantuml_markdown.py @@ -130,7 +130,7 @@ def __init__(self, md): self._cachedir: Optional[str] = None self._plantuml_server: Optional[str] = None self._kroki_server: Optional[str] = None - self._base_dir: Optional[str | List[str]] = None + self._base_dir: Optional[List[str]] = None self._encoding: str = 'utf-8' self._http_method: str = 'GET' self._fallback_to_get: bool = True @@ -144,12 +144,23 @@ def run(self, lines: List[str]) -> List[str]: self._encoding = self.config['encoding'] or self._encoding self._http_method = self.config['http_method'].strip() self._fallback_to_get = bool(self.config['fallback_to_get']) - self._config_path = self.config['config'] self._base_dir = self.config['base_dir'] if isinstance(self._base_dir, str): self._base_dir = [self._base_dir] + self._config_path = self.config['config'] + + if self.config['config']: + # try to find config file + for search_dir in self._base_dir: + if os.path.isfile(os.path.join(search_dir, self.config['config'])): + self._config_path = os.path.join(search_dir, self.config['config']) + break + else: + logger.error(f'Could not find config file {self._config_path} in any of {self._base_dir}') + return [self._render_error(f'Could not find config file {self._config_path} in any of {self._base_dir}')] + text = '\n'.join(lines) idx = 0 @@ -447,8 +458,7 @@ def _render_local_uml_image(self, plantuml_code: str, img_format: str) -> Tuple[ cmdline.extend(['-pipemap' if img_format == 'map' else '-p', "-t" + img_format, '-charset', 'UTF-8']) if self._config_path: - full_path = os.path.join(self._base_dir, self._config_path) if self._base_dir else self._config_path - cmdline.extend(['-config', full_path]) + cmdline.extend(['-config', self._config_path]) try: # On Windows run batch files through a shell so the extension can be resolved From 35f7e1c250e44bd2ac65936b32c3cbf74d35bb1a Mon Sep 17 00:00:00 2001 From: Michele Tessaro Date: Sat, 3 Aug 2024 15:46:12 +0200 Subject: [PATCH 2/3] chg: doc: added a warning on `plantuml` script output (see end of #63) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 592da1c..336e86b 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,10 @@ java %PLANTUML_JAVAOPTS% -jar %mypath%\plantuml.jar %* Make sure the `plantuml.bat` is on the path. +**IMPORTANT NOTE**: the whole output of the script `plantuml` (or `plantuml.bat` in Windows) is captured and saved as +image, so be sure no other output is done by the script, even blank lines. For example, the first line of the +`plantuml.bat` script **MUST** be `@echo off`. + For [Gentoo Linux][Gentoo] there is an ebuild at http://gpo.zugaina.org/dev-util/plantuml/RDep: you can download the ebuild and the `files` subfolder or you can add the `zugaina` repository with [layman][] (recommended). From 438f6fabd5119470510a029ab609073cbd7c792c Mon Sep 17 00:00:00 2001 From: Michele Tessaro Date: Sat, 3 Aug 2024 15:47:33 +0200 Subject: [PATCH 3/3] chg: pkg: changed version for the new release --- CHANGELOG.md | 11 +++++++++++ setup.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bbb8e..5aa2512 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Changelog +## 3.10.1 (2024-08-03) + +### Changes + +* Added a warning on `plantuml` script output (see end of #63) [Michele Tessaro] + +### Fix + +* Fixed plantuml config file path with local rendering (fixes #101) [Michele Tessaro] + + ## 3.10.0 (2024-08-01) ### Fix diff --git a/setup.py b/setup.py index ac5fe99..71148c0 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setuptools.setup( name="plantuml-markdown", - version="3.10.0", + version="3.10.1", author="Michele Tessaro", author_email="michele.tessaro.tex@gmail.com", description="A PlantUML plugin for Markdown",