jira2markdown
jira2markdown copied to clipboard
Converting Jira lists with CRLF line-breaks adds erroneous whitespace to subsequent text
When using jira2markdown
's convert()
function on Jira lists with Carriage Return (CR) Line Feed (LF) (CRLF) style line-breaks the resulting markdown text adds erroneous whitespace to subsequent text after the last list item.
See below for a visual example of the conversion issue.
from jira2markdown import convert
jira_text = 'Line Before List: Sample text words words words:\r\n * Bulleted Item 1: Sample text words words words\r\n * Bulleted Item 2: Sample text words words words\r\n\r\nLine After List: Sample text words words words\r\nLine After List: Sample text words words words'
print(jira_text)
Input (jira_text
printed):
Line Before List: Sample text words words words:
* Bulleted Item 1: Sample text words words words
* Bulleted Item 2: Sample text words words words
Line After List: Sample text words words words
Line After List: Sample text words words words
Input (jira_text
with line-breaks visualized):
Line Before List: Sample text words words words:\r\n
* Bulleted Item 1: Sample text words words words\r\n
* Bulleted Item 2: Sample text words words words\r\n
\r\n
Line After List: Sample text words words words\r\n
Line After List: Sample text words words words
md_text = convert(jira_text)
Expected Output (md_text
printed):
Line Before List: Sample text words words words:
- Bulleted Item 1: Sample text words words words
- Bulleted Item 2: Sample text words words words
Line After List: Sample text words words words
Line After List: Sample text words words words
Expected Output (md_text
with line-breaks visualized):
Line Before List: Sample text words words words:\r\n
- Bulleted Item 1: Sample text words words words\r\n
- Bulleted Item 2: Sample text words words words\r\n
\r\n
Line After List: Sample text words words words\r\n
Line After List: Sample text words words words\r\n
print(md_text)
Actual Output (md_text
printed):
Line Before List: Sample text words words words:
- Bulleted Item 1: Sample text words words words
- Bulleted Item 2: Sample text words words words
Line After List: Sample text words words words
Line After List: Sample text words words words
Actual Output (md_text
with line-breaks visualized):
Line Before List: Sample text words words words:\r\n
- Bulleted Item 1: Sample text words words words\n
- Bulleted Item 2: Sample text words words words\n
\n
Line After List: Sample text words words words\n
Line After List: Sample text words words words
As shown the conversion ends up replacing:
-
\r\n
in the list with\n
-
\r\n\r\n
at the end of the list with\n \n
-
\r\n
after the list with\n
Copy-and-Pasteable Snippet to replicate the issue:
from jira2markdown import convert
# Input with CRLF line-breaks
jira_text = 'Line Before List: Sample text words words words:\r\n * Bulleted Item 1: Sample text words words words\r\n * Bulleted Item 2: Sample text words words words\r\n\r\nLine After List: Sample text words words words\r\nLine After List: Sample text words words words'
# Print input with line-breaks rendered
print("\njira_text:\n" + jira_text)
# Print input with line-breaks represented, not rendered
print("\nrepr(jira_text):\n" + repr(jira_text))
md_text = convert(jira_text)
# Print output with line-breaks rendered
print("\nmd_text:\n" + md_text)
# Print output with line-breaks represented, not rendered
print("\nrepr(md_text):\n" + repr(md_text))