Skip to content

Commit 5346a96

Browse files
fix(jira): markdown multi level bullet list
1 parent ca05d51 commit 5346a96

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

src/mcp_atlassian/preprocessing/jira.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,23 +313,27 @@ def save_inline_code(match: re.Match) -> str:
313313
)
314314

315315
# Multi-level bulleted list
316+
def bulleted_list_fn(match: re.Match) -> str:
317+
ident = len(match.group(1)) if match.group(1) else 0
318+
level = ident // 2 + 1
319+
return str("*" * level + " " + match.group(2))
320+
316321
output = re.sub(
317-
r"^(\s*)- (.*)$",
318-
lambda match: (
319-
"* " + match.group(2)
320-
if not match.group(1)
321-
else " " * (len(match.group(1)) // 2) + "* " + match.group(2)
322-
),
322+
r"^(\s+)?[-+*] (.*)$",
323+
bulleted_list_fn,
323324
output,
324325
flags=re.MULTILINE,
325326
)
326327

327328
# Multi-level numbered list
329+
def numbered_list_fn(match: re.Match) -> str:
330+
ident = len(match.group(1)) if match.group(1) else 0
331+
level = ident // 2 + 1
332+
return str("#" * level + " " + match.group(2))
333+
328334
output = re.sub(
329-
r"^(\s+)1\. (.*)$",
330-
lambda match: "#" * (int(len(match.group(1)) / 4) + 2)
331-
+ " "
332-
+ match.group(2),
335+
r"^(\s+)?\d+\. (.*)$",
336+
numbered_list_fn,
333337
output,
334338
flags=re.MULTILINE,
335339
)

tests/test_preprocessing.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ def test_markdown_to_jira(preprocessor_with_jira):
272272
- Feature 1
273273
- Feature 2
274274
275+
### Bulet Lists
276+
* Item A
277+
* Sub-item A.1
278+
* Sub-sub-item A.1.1
279+
* Item B
280+
281+
### Numbered lists
282+
1. NumItem A
283+
1. Sub-NumItem A.1
284+
1. Sub-sub-NumItem A.1.1
285+
2. Sub-sub-NumItem A.1.2
286+
2. Item B
287+
275288
### Code Example
276289
```python
277290
def hello():
@@ -286,6 +299,8 @@ def hello():
286299
assert "h2. Introduction" in converted
287300
assert "*improve*" in converted
288301
assert "* Feature 1" in converted
302+
assert "*** Sub-sub-item A.1.1" in converted
303+
assert "### Sub-sub-NumItem A.1.2" in converted
289304
assert "{code:python}" in converted
290305
assert "[our website|https://example.com]" in converted
291306

0 commit comments

Comments
 (0)