Repository navigation
fix(jira): stop a blank line before ---- becoming an empty h2. - #1590
Merged
sooperset merged 1 commit intoAug 17, 2026
Merged
Conversation
The setext heading rule matched `^(.*?)\n([=-])+$`, and `(.*?)` matches the
empty string, so a horizontal rule preceded by a blank line consumed that
blank line as its heading text:
"before\n\n----\n\nafter" -> "before\nh2. \n\nafter"
The rule was destroyed and an empty `h2.` appeared in its place. A setext
underline requires actual text on the line above it, so a lookahead now
demands at least one non-whitespace character there. `----` on its own line
is then left alone, which is already the Jira markup for a horizontal rule.
Legitimate setext headings are unaffected, including a rule directly under a
text line with no blank between them, which CommonMark defines as a setext
underline rather than a thematic break.
Closes sooperset#1587
Contributor
|
@amitvijapur, the focused regression coverage here is excellent: it protects the blank-line horizontal-rule case while confirming both setext heading levels still convert correctly. Thanks for keeping the regex change narrow and documenting the mixed-underline edge case separately. |
sanderma
pushed a commit
to sanderma/mcp-atlassian
that referenced
this pull request
Aug 18, 2026
Conflict resolution keeps the mistletoe/jira2markdown conversion pipeline and reconciles the upstream fixes that patched the removed regex engine: - sooperset#1361 (intraword underscores italicized): adopted as policy in the renderer's escaper - * and _ are escaped whenever they touch non-whitespace because Jira applies emphasis intraword; the boundary-only effects (- + ^ ~) keep the lenient rule so dates and hyphenated words stay readable. - sooperset#1587/sooperset#1590 (blank line before ---- became an empty h2.): subsumed by the CommonMark parser; a thematic break now also keeps a blank line after the rule. - sooperset#1379 (markdown table parsing): subsumed by mistletoe's table support. - sooperset#1476 (segmented issue keys): ported _ISSUE_KEY_PATTERN into _process_smart_links. The tool-description conflicts merge both sides (Markdown contract wording plus upstream's Cloud expand hint and body/comment alias). types-cachetools returns to upstream's constraint now that the TTLCache annotation this branch patched was removed upstream. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0111CE62sJaCyTPbdqGEMpMG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
markdown_to_jiraturned a horizontal rule that follows a blank line into anempty
h2., losing the rule:The setext heading rule matched
^(.*?)\n([=-])+$. Because(.*?)also matchesthe empty string, the blank line above
----was consumed as the heading's text.A setext underline needs actual text on the line above it, so a lookahead now
requires at least one non-whitespace character there.
----on its own line isthen left untouched, which is already the Jira markup for a horizontal rule, so
no separate rule handling is needed.
Fixes: #1587
Changes
preprocessing/jira.py: added a(?=[^\n]*\S)lookahead to the setext headingpattern so a blank or whitespace-only line cannot be treated as heading text.
TestSetextHeadingsclass covering both the bug and the behaviour thatmust not regress.
Legitimate setext headings are unaffected, including a rule placed directly under
a text line with no blank line between them — CommonMark treats that as a setext
underline rather than a thematic break, and it still converts to
h2..Testing
change and confirmed it is correct after.
Six new tests in
tests/unit/preprocessing/test_preprocessing.py:before\n\n----\n\nafter----\n\nafter(leading rule)----My Heading\n---\nbodyh2. My HeadingMy Heading\n===\nbodyh1. My HeadingSome text\n----\nbodyh2. Some textFull unit suite: 3817 passed, 5 skipped.
pre-commit runpasses on thechanged files, including ruff-format, ruff and mypy.
Checklist
Note
While here I noticed
([=-])+also accepts a mixed run, soTitle\n=-=-istreated as a heading and
match.group(2)[0]reads the last character rather thanthe first. Left alone to keep this focused on the reported bug — happy to send a
follow-up if you would like that tightened to
(=+|-+).