Repository navigation
fix(workflow): check draft links past unclosed inner code examples (fixes #401) - #407
Conversation
issue_drafts() stripped nested examples via unfenced(block), whose reparse dropped every line from an unclosed inner fence onward, so a draft pointer after an unclosed embedded example was never checked (#401, residual of #393/#400). - fenced_blocks() now has a closure-aware sibling (_fenced_blocks); when a draft's own fence was never closed at document level, a trailing bare fence line in the block is the draft's closing fence (consumed as the example's close) and is dropped before stripping. - New draft_prose() strips examples from a draft with recovery: a bare fence closes the innermost example whatever its length (the 4-open/3-close slip), and an example still open at the end of the draft has its buffered lines kept as prose and checked instead of dropped. A properly closed example's contents stay exempt. Four regression tests cover both shapes with broken and valid pointers; the two broken-pointer tests fail pre-fix. Full workflow suite: 52 passed. Real-tree check returns ok: true. Fixes #401
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fa3ff6f27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if stack and token[0] == stack[-1][0] and not info: | ||
| stack.pop() |
There was a problem hiding this comment.
Respect shorter literal fences inside code examples
When a valid embedded example uses a longer fence, every shorter bare run of the same character is literal content, but this branch pops the stack regardless of length. For example, a four-backtick Markdown example containing a three-backtick snippet is treated as closed at the snippet delimiter, so a link such as [example](missing.md) later in that code is incorrectly checked and can make check reject an otherwise valid document. Preserve the normal len(token) >= len(stack[-1]) rule for well-formed blocks while applying short-close recovery only when the parser can establish that the example is actually malformed.
Useful? React with 👍 / 👎.
| if found and not found[2]: | ||
| block = "\n".join(lines[:-1]) |
There was a problem hiding this comment.
Preserve a trailing embedded-example closing fence
When an unclosed outer draft ends immediately after a properly closed embedded example and its workflow:issue marker appears before that example, closed is false but the final bare fence belongs to the example, not to the draft. Unconditionally deleting it makes draft_prose() treat the example as unclosed and expose links inside its code to validation, so an illustrative [example](missing.md) causes check to reject a draft shape that the unclosed-draft recovery otherwise supports. Only discard the fence after establishing that it was consumed as the outer draft's intended close.
Useful? React with 👍 / 👎.
Problem
PR #400's nesting-aware fence scanner (fixes #393) still lets a trigger-issue draft escape the link check when the draft's embedded code example is itself unclosed. Everything in the draft from the example's opening fence onward was stripped before link checking, so any pointer after the example was silently unchecked — the same silent-escape failure mode as #382 / #391 / #393.
Two shapes reproduced on main 2b9b424 (verified again this run pre-fix):
Solution
fenced_blocks()gains a closure-aware sibling (_fenced_blocks()yielding (block, closed)); when a draft's own fence was never closed at document level, a trailing bare fence line in the block is the draft's closing fence (mis-consumed as the example's close) and is dropped before stripping.draft_prose()strips examples with recovery: a bare fence closes the innermost example whatever its length (the 4-open/3-close slip), and an example still open at the end of the draft has its buffered lines kept as prose and checked instead of dropped — consistent with fix(workflow): check draft links past inner code fences (#393) #400's "checked rather than silently dropped" principle. Properly closed examples stay exempt.Verification
python3 scripts/research_workflow.py check --repo-root .returns ok: true on the real tree.Fixes #401
Need help on this PR? Tag
@codesmith-botwith what you need.