fix(template/dotnet): switch link-prefix step to paren-aware Python walker#29
Conversation
…alker 995 broken-link errors on #28 because the sed regex did not match DefaultDocumentation's link forms: ](ResQ.Blockchain.md 'qualified.Type') The trailing space + 'title' before `)` falls outside the `[^)/]*` URL character class, so the regex skipped these links entirely and they kept their bare-filename form. Mintlify rejected all 995 of them. Replace the sed step with a paren-balanced Python walker (same shape used elsewhere in this template family). It correctly handles: - bare `(path.md)` - `(path.md#anchor)` - `(path.md 'title')` and double-quoted variants - method-overload pages with parens in the filename, e.g. `Foo.Bar(string,int).md` Sync PR will reapply the same fix to dotnet-sdk:main.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR replaces a simplistic sed-based Markdown link rewriter in a GitHub Actions workflow with a Python script that safely handles paren-balanced link detection, skips content inside code blocks, and prefixes bare ChangesMarkdown Link Rewriting Step
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request replaces the sed-based link prefixing logic in the .NET API documentation template with a Python script to better handle complex Markdown links, such as those with titles or parentheses in filenames. Feedback was provided to enhance the script by ensuring it ignores inline code spans to prevent accidental modification of links within code snippets.
| while i < n: | ||
| j = line.find("](", i) |
There was a problem hiding this comment.
The current walker does not account for inline code spans (e.g., code-enclosed links). According to the general rules for Markdown post-processing, the logic should respect CommonMark inline code span rules—specifically by counting backtick run lengths—to avoid incorrectly modifying content inside code snippets. This ensures that examples or documentation about links are not inadvertently rewritten.
while i < n:
if line[i] == chr(96):
r = 0
while i + r < n and line[i + r] == chr(96): r += 1
end = line.find(chr(96) * r, i + r)
if end != -1:
out.append(line[i:end + r])
i = end + r
continue
j = line.find("](", i)References
- When processing Markdown/MDX files to escape curly braces for JSX compatibility, ensure the logic ignores content within inline code spans (backticks) to prevent breaking code snippets.
Fixes resq-software/docs#28 (995 broken links).
DefaultDocumentation emits links with title attributes:
The sed regex expected
)immediately after.md(with optional#anchor) and skipped these entirely, so 995 bare-filename links never got the./prefix. Mintlify rejected all of them.Replace with a paren-balanced Python walker (same shape used elsewhere). Handles:
(path.md)(path.md#anchor)(path.md 'title')and double-quoted variantsFoo.Bar(string,int).mdSync PR will reapply the same fix to dotnet-sdk:main.
Summary by CodeRabbit