Skip to content

fix(markdown): ignore headings inside HTML comments when replacing sections - #5702

Closed
CJstate wants to merge 1 commit into
github:mainfrom
CJstate:fix/markdown-section-html-comments
Closed

CJstate wants to merge 1 commit into
github:mainfrom
CJstate:fix/markdown-section-html-comments

Conversation

@CJstate

@CJstate CJstate commented Dec 4, 2026

Copy link
Copy Markdown

replace_section() scanned headings line by line without tracking CommonMark HTML comments, so a heading inside <!-- ... --> was treated as a real section boundary. Depending on the comment position, that made the selector ambiguous or truncated the selected section at a comment-only heading.

This change skips HTML comment blocks while preserving fences: comment markers inside fenced code are ignored, fences inside comments are ignored, and a heading on the line that closes a comment is still part of the comment. Regression tests cover LF/CRLF/CR, single-line comments, indented comment markers, unclosed comments, and comment-close lines.

Validation: .venv/Scripts/python.exe -m pytest tests/test_markdown_sections.py -q — 114 passed.

Signed-off-by: CJstate 142857225+CJstate@users.noreply.github.com
Assisted-by: DSH agent lead (model: Tencent Hunyuan Hy, autonomous)

@CJstate
CJstate requested a review from mnriem as a code owner December 4, 2026 11:36
Copilot AI adaptive review requested due to automatic review settings December 4, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The comment-block parser misses terminators overlapping the opener, causing section replacement to delete unrelated sections.

1 open issue
What changed in this PR

Updates Specify’s Markdown section replacement to ignore headings inside HTML comment blocks while preserving fenced-code handling.

Changes:

  • Tracks comment boundaries during heading scanning.
  • Adds regression coverage for newline variants, comment boundaries, indentation, and fence interactions.

AI-generated review for the requester by GitHub Copilot (model: unknown; autonomous).

File Description
tests/​test_markdown_sections.py Adds comment-handling regression tests.
src/​specify_cli/​markdown_sections.py Skips HTML comment blocks when locating sections.

Review effort: Balanced (adaptive)

Comment thread src/specify_cli/markdown_sections.py Outdated
continue
comment_open = re.match(r" {0,3}<!--", text)
if comment_open:
if "-->" not in text[comment_open.end():]:
@mnriem mnriem added the triage-must-have Verdict: high-value, important work for Spec Kit — do first label Dec 4, 2026
@mnriem

mnriem commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback and resolve conflicts

Rebase the PR branch onto current main. The HTML-comment heading fix in this PR
is already implemented upstream by commit c76e7be
("Ignore HTML comment blocks during Markdown section replacement (github#5683)").

Signed-off-by: CJstate <142857225+CJstate@users.noreply.github.com>
@CJstate
CJstate force-pushed the fix/markdown-section-html-comments branch from f4064f5 to 75a6b30 Compare December 5, 2026 11:24
Copilot AI adaptive review requested due to automatic review settings December 5, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Still open (1)

@CJstate

CJstate commented Dec 5, 2026

Copy link
Copy Markdown
Author

Closing as superseded: ignoring headings inside HTML comments during Markdown section replacement is already in upstream main via commit c76e7be ("Ignore HTML comment blocks during Markdown section replacement (#5683)"). This branch is now synced to main with no remaining diff.

@CJstate CJstate closed this Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-must-have Verdict: high-value, important work for Spec Kit — do first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants