Skip to content

Commit

Permalink
Merge branch 'release/3.9.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikitex70 committed Apr 24, 2024
2 parents ff45d1c + e362985 commit 329f74a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Changelog


## 3.9.5 (2024-04-22)
## 3.9.6 (2024-04-24)

### Fix
### New

* Fixed caching with png diagrams with no links (fixes #27) [Michele Tessaro]
* `cachedir` is auto-created if missing (implements #96) [Michele Tessaro]

### Other

* @łip. [Michele Tessaro]
## 3.9.5 (2024-04-22)

### Fix

* Fixed caching with png diagrams without hyperlinks (fixes #27) [Michele Tessaro]


## 3.9.4 (2024-03-26)
Expand Down
1 change: 1 addition & 0 deletions plantuml_markdown/plantuml_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def _render_diagram(self, code: str, requested_format: str) -> Tuple[Optional[by
diagram = None

if self._cachedir:
os.makedirs(self._cachedir, exist_ok=True)
diagram_hash = "%08x" % (adler32(code.encode('UTF-8')) & 0xffffffff)
cached_diagram_file = os.path.expanduser(
os.path.join(self._cachedir, diagram_hash + '.' + requested_format))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setuptools.setup(
name="plantuml-markdown",
version="3.9.5",
version="3.9.6",
author="Michele Tessaro",
author_email="[email protected]",
description="A PlantUML plugin for Markdown",
Expand Down
17 changes: 17 additions & 0 deletions test/test_plantuml.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,20 @@ def test_retries(self):
text = self.text_builder.diagram('A -> B').format('txt').build()
self.assertEqual('<pre><code class="text">dummy</code></pre>',
self.md.convert(text))

def test_cachedir(self):
"""
Verify that `cachedir` is created if it does not exist
"""
temp_dir = tempfile.TemporaryDirectory()
cache_dir = os.path.join(temp_dir.name, 'cache', 'dir')
self.md = markdown.Markdown(extensions=['plantuml_markdown'],
extension_configs={
'plantuml_markdown': {
'cachedir': cache_dir,
}
})
text = self.text_builder.diagram("A --> B").build()
self.md.convert(text)
self.assertTrue(os.path.exists(cache_dir))
temp_dir.cleanup()

0 comments on commit 329f74a

Please sign in to comment.