Skip to content

Commit ac3dec1

Browse files
authored
Fix #1030: truncate resulting Jira instead of markdown source (#1031)
1 parent eec3737 commit ac3dec1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

jbi/jira/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def markdown_to_jira(markdown: str, max_length: int = 0) -> str:
99
"""
1010
Convert markdown content into Jira specific markup language.
1111
"""
12-
if max_length > 0 and len(markdown) > max_length:
12+
jira_output = pypandoc.convert_text(markdown, "jira", format="gfm").strip()
13+
if max_length > 0 and len(jira_output) > max_length:
1314
# Truncate on last word.
14-
markdown = markdown[:max_length].rsplit(maxsplit=1)[0]
15-
return pypandoc.convert_text(markdown, "jira", format="gfm").strip() # type: ignore
15+
jira_output = jira_output[:max_length].rsplit(maxsplit=1)[0]
16+
return jira_output # type: ignore

tests/unit/jira/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def test_markdown_to_jira_with_malformed_input():
7171
("aa\taaa", "aa", 5),
7272
("aaaaaa", "aaaaa", 5),
7373
("aaaaa ", "aaaaa", 5),
74+
("`fo` `fo`", "{{fo}}", 9),
7475
],
7576
)
7677
def test_markdown_to_jira_with_max_chars(markdown, expected, max_length):

0 commit comments

Comments
 (0)