Skip to content

Support Markdown variants for follow-up headings#81

Merged
wwind123 merged 1 commit into
mainfrom
codex/issue-80-markdown-followup-headings
May 18, 2026
Merged

Support Markdown variants for follow-up headings#81
wwind123 merged 1 commit into
mainfrom
codex/issue-80-markdown-followup-headings

Conversation

@wwind123
Copy link
Copy Markdown
Owner

Summary

  • Share conservative follow-up heading regex construction across same-PR, future, and legacy sections
  • Accept full-heading bold markers and a single trailing colon or period for known follow-up headings
  • Add regression coverage for bolded headings, period headings, and unrelated bold heading termination

Tests

  • python3 -m pytest tests/test_agent_loop.py -k followups
  • python3 -m pytest

Closes #80

@wwind123
Copy link
Copy Markdown
Owner Author

Implemented issue #80 and opened PR #81:

#81

Changed protocol.py to recognize approved follow-up headings with full-heading bold markers and a single trailing : or ., while keeping matching limited to the known section names. Added regression tests for bolded headings, period headings, bold-plus-punctuation variants, and unrelated bold heading termination.

Tests passed:
python3 -m pytest tests/test_agent_loop.py -k followups
python3 -m pytest

-- OpenAI Codex

@wwind123
Copy link
Copy Markdown
Owner Author

Review: Support Markdown variants for follow-up headings (#81)

The implementation cleanly addresses issue #80. Here's my analysis:

Regex correctness

The _followup_heading_re helper generates a three-way alternation for each known heading title:

  1. {title}[:.]? — plain text with optional trailing : or .
  2. \*\*{title}\*\*[:.]? — bold (**title**) with optional punctuation outside the bold markers
  3. \*\*{title}[:.]?\*\* — bold with optional punctuation inside the bold markers

All eight meaningful variants are covered: plain (no punct, :, .), bold-outside-punct (no punct, :, .), and bold-inside-punct (:, .). The overlap on the no-punctuation bold case (matched by both alt 2 and alt 3) is harmless.

The #{{2,6}} in the f-string correctly collapses to the literal #{2,6} in the compiled pattern. The [:.] character class is correct — . loses its special meaning inside [], so it matches a literal period only.

Interaction with ANY_HEADING_RE

ANY_HEADING_RE = re.compile(r"^\s*#{1,6}\s+\S") correctly stops parsing at unrelated bold headings like ### **Notes** because ** starts with \S. The new test test_parse_approved_followups_stops_at_unrelated_bold_heading verifies this boundary condition, which is the key risk area.

Test coverage

The parametrized test covers three representative variant groups (plain bold, bold with mixed punctuation positions, and plain-with-period), and the stop test verifies the parse-termination behavior. This is sufficient coverage for the feature as specified.

Title injection concern

The title parameter is an internal regex fragment, not user-controlled input. No escaping is needed, and the type annotation title: str adequately documents the contract for maintainers.

No blocking issues found.

-- Anthropic Claude

@wwind123
Copy link
Copy Markdown
Owner Author

Warning: True color (24-bit) support not detected. Using a terminal with true color enabled will result in a better visual experience.
YOLO mode is enabled. All tool calls will be automatically approved.
YOLO mode is enabled. All tool calls will be automatically approved.
Ripgrep is not available. Falling back to GrepTool.
Error executing tool list_directory: Error: Failed to list directory.
The changes in PR #81 correctly implement support for Markdown variants in follow-up headings, specifically addressing bolded headings and common punctuation (colons and periods).

Analysis

  • Regex Robustness: The _followup_heading_re helper function effectively handles various combinations of bolding and punctuation. It supports both ### **Title**: and ### **Title:**, which are common patterns when LLMs generate Markdown.
  • Surgical Implementation: The refactor from static regexes to a helper function reduces duplication and makes the code more maintainable while precisely targeting the requested variants.
  • Test Coverage: The new test cases in tests/test_agent_loop.py comprehensively cover the reported scenarios, including different combinations of bolding and punctuation, as well as verifying that unrelated bolded headings correctly stop the follow-up parsing.
  • Verification: Verified that all 141 tests pass in the PR branch.

The implementation is clean, well-tested, and directly fulfills the requirements of Issue #80.

-- Google Gemini

@wwind123 wwind123 merged commit 8f13fa6 into main May 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow up future review note: **Markdown Variants**: Consider supporting other common Markdown variants such as bolded h

1 participant