Skip to content

Commit

Permalink
fix: usr: fixed corrupted inline svg images (fixes #90)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikitex70 committed Jun 22, 2023
1 parent ab5ad5f commit 17d348b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# Changelog


## 3.9.2 (2023-06-22)

### Fix

* Fixed corrupted inline svg images (fixes #90) [Michele Tessaro]


## 3.9.1 (2023-04-27)

### Changes

* Updated the changelog. [Michele Tessaro]

### Fix

* Fixed handle of other diagram types with plantuml server. [Michele Tessaro]
Expand Down
8 changes: 4 additions & 4 deletions plantuml_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,13 @@ def _image_tag(self, img_format: str, diagram: bytes, options: Dict[str, Optiona
else: # png format, explicitly set or as a default when format is not recognized
return self._png_image(diagram, options, code)

@staticmethod
def _txt_code(diagram: bytes) -> str:
def _txt_code(self, diagram: bytes) -> str:
# logger.debug(diagram)
img = etree.Element('pre')
code = etree.SubElement(img, 'code')
code.attrib['class'] = 'text'
code.text = AtomicString(diagram.decode('UTF-8'))
return etree.tostring(img, short_empty_elements=True).decode()
return self.md.htmlStash.store(etree.tostring(img, short_empty_elements=True).decode())

def _inline_svg_image(self, diagram: bytes, options: Dict[str, Optional[str]]) -> str:
data = self.ADAPT_SVG_REGEX.sub('<svg \\1\\2>', diagram.decode('UTF-8'))
Expand All @@ -255,7 +254,8 @@ def _inline_svg_image(self, diagram: bytes, options: Dict[str, Optional[str]]) -
img.attrib['style'] = re.sub(r'\b(?:width|height):\d+px;', '', img.attrib['style'])
img.attrib['preserveAspectRatio'] = 'xMaxYMax meet'
self._set_tag_attributes(img, options)
return etree.tostring(img, short_empty_elements=True).decode()

return self.md.htmlStash.store(etree.tostring(img, short_empty_elements=True).decode())

def _svg_image(self, diagram: bytes, options: Dict[str, Optional[str]]) -> str:
# Firefox handles only base64 encoded SVGs
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.1",
version="3.9.2",
author="Michele Tessaro",
author_email="michele.tessaro@email.it",
description="A PlantUML plugin for Markdown",
Expand Down

0 comments on commit 17d348b

Please sign in to comment.