Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/mcp_atlassian/preprocessing/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,12 @@ def _jira_code_to_md(match: re.Match[str]) -> str:
# Block quotes
output = re.sub(r"^bq\.(.*?)$", r"> \1\n", output, flags=re.MULTILINE)

# Text formatting (bold, italic)
# Text formatting (bold, italic). Delimiters preceded by a backslash
# are wiki escapes (e.g. the intraword `\_` this module's
# markdown_to_jira writes), not markup, so they must neither open nor
# close a span.
output = re.sub(
r"([*_])(.*?)\1",
r"(?<!\\)([*_])(.*?)(?<!\\)\1",
lambda match: (
("**" if match.group(1) == "*" else "*")
+ match.group(2)
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/preprocessing/test_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,24 @@ def test_jira_to_markdown(preprocessor_with_jira):
assert preprocessor_with_jira.jira_to_markdown("*bold text*") == "**bold text**"
assert preprocessor_with_jira.jira_to_markdown("_italic text_") == "*italic text*"

# Test escaped delimiters are preserved, not paired as emphasis (issue #1610)
assert (
preprocessor_with_jira.jira_to_markdown(r"QUALITY\_GATES\_LLM\_ENABLED")
== r"QUALITY\_GATES\_LLM\_ENABLED"
)
assert preprocessor_with_jira.jira_to_markdown(r"foo\_bar") == r"foo\_bar"
assert (
preprocessor_with_jira.jira_to_markdown(r"my\_var\_x and her\_var")
== r"my\_var\_x and her\_var"
)
assert "*" not in preprocessor_with_jira.jira_to_markdown(
r"my\_var\_x and her\_var"
)
assert (
preprocessor_with_jira.jira_to_markdown(r"escaped \*stars\* stay literal")
== r"escaped \*stars\* stay literal"
)

# Test code blocks
assert preprocessor_with_jira.jira_to_markdown("{{code}}") == "`code`"

Expand Down
Loading