Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 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)
| continue | ||
| comment_open = re.match(r" {0,3}<!--", text) | ||
| if comment_open: | ||
| if "-->" not in text[comment_open.end():]: |
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
force-pushed
the
fix/markdown-section-html-comments
branch
from
December 5, 2026 11:24
f4064f5 to
75a6b30
Compare
Contributor
There was a problem hiding this comment.
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)
- 🔴 src/specify_cli/markdown_sections.py#L166 — CommonMark type-2 blocks end when
-->appears anywhere on the opening line, including the…
Author
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.

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)