Skip to content

Commit

Permalink
Change return format of images with properties
Browse files Browse the repository at this point in the history
  • Loading branch information
vasokot committed Nov 22, 2024
1 parent 5971ced commit d5ebfec
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Restore virtualenv from cache
id: cache
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('poetry.lock') }}
Expand Down
2 changes: 1 addition & 1 deletion jira2markdown/markup/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def action(self, tokens: ParseResults) -> str:
if name in self.ALLOWED_ATTRS
)
if attrs_str:
return f'<img src="{tokens.url}" {attrs_str} />'
return f"![{tokens.url}]({tokens.url})" + "{" + attrs_str + "}"
else:
return f"![{tokens.url}]({tokens.url})"

Expand Down
4 changes: 2 additions & 2 deletions tests/markup/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def test_url_line_break(self):
assert convert("!http://example.\ncom/image.png!") == "!http://example.\ncom/image.png!"

def test_image_attributes(self):
assert convert("!image.jpg|width=300!") == '<img src="image.jpg" width="300" />'
assert convert("!image.jpg| WIDTH = 300 , HEIGHT=200!") == '<img src="image.jpg" width="300" height="200" />'
assert convert("!image.jpg|width=300!") == '![image.jpg](image.jpg){width="300"}'
assert convert("!image.jpg| WIDTH = 300 , HEIGHT=200!") == '![image.jpg](image.jpg){width="300" height="200"}'
assert convert("!image.jpg|align=right, vspace=4!") == "![image.jpg](image.jpg)"
4 changes: 2 additions & 2 deletions tests/markup/test_mixed_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def test_basic_markup(self):
)

def test_cell_image(self):
assert convert("|!image.png|width=300!") == '|<img src="image.png" width="300" />|\n|---|\n'
assert convert("|!image.png|width=300!") == '|![image.png](image.png){width="300"}|\n|---|\n'

def test_cell_link(self):
assert convert("|[link|http://example.com]|") == "|[link](http://example.com)|\n|---|\n"
Expand All @@ -285,7 +285,7 @@ def test_text_formatting(self):
== """
> **My Title**
> a block of text surrounded with a **panel**
> line with <img src="image.png" width="300" />
> line with ![image.png](image.png){width="300"}
"""
)

Expand Down

0 comments on commit d5ebfec

Please sign in to comment.