fix(docs): catch bare <word> tags in MDX safety check#1170
Conversation
Add check 5 to tools/check-docs-mdx for bare angle-bracket placeholders (<name>, <phase>, etc.) that break Fern's MDX parser. Strip backslash-escaped patterns (\<word\>) to avoid false positives. Collapse cross-line inline code spans in validator.md and collector.md so the per-line backtick stripper correctly excludes them. Fixes NVIDIA#1147
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR extends the MDX safety lint tool to detect bare angle-bracket placeholders ( Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
mchmarny
left a comment
There was a problem hiding this comment.
Welcome to AICR, @pedjak — thanks for picking this up. The fix is well-scoped: check 5 follows the same shape as the existing check 4, the backslash-escape strip is the right complement to the inline-code strip, and the two cross-line backtick spans in validator.md / collector.md are exactly the kind of collateral fix that has to land in the same PR (the per-line gsub stripper can't see across lines).
Verified locally that the script still passes clean on all docs and correctly flags a bare <word> while leaving \<word\> and `<word>` alone.
Two low-priority observations inline — both about edge cases the predicate doesn't cover (lines with mixed content, and non-void HTML containers like <details>). Neither blocks merge; flagged for future iteration. PR is behind main, so a rebase + force-push will be needed before merge, and CI requires NVIDIA-runner vetting for a first-time contributor.
LGTM.
| # Bare angle-bracket placeholders: <word> that are not void HTML | ||
| # elements (check 1) or autolinks (check 4). MDX interprets these | ||
| # as JSX component tags. | ||
| line ~ /<[a-zA-Z]/ && line !~ /<(img|br|hr|input|source|meta|link|area|base|col|embed|param|track|wbr)([ \t>\/])/ && line !~ /<https?:\/\// { |
There was a problem hiding this comment.
nit: line-level negation means a line containing both a void element (or autolink) and a bare <word> won't flag the placeholder. Reproduced:
$ echo '<br /> and <foo>' > t.md && bash tools/check-docs-mdx /path/with/t.md
OK
The void-element regex matches anywhere on the line, suppressing the whole line. Same shape as check 4 (autolinks), so this is consistent with existing code — flagging as an observation, not a request to change. If you wanted positional accuracy you'd strip the void/autolink matches from line (like inline code spans are stripped on lines 67/70) before the bare-tag predicate.
There was a problem hiding this comment.
Actually, this is a blocker, the project docs generator will fail until this is resolved. Otherwise this LGTM
| # Bare angle-bracket placeholders: <word> that are not void HTML | ||
| # elements (check 1) or autolinks (check 4). MDX interprets these | ||
| # as JSX component tags. | ||
| line ~ /<[a-zA-Z]/ && line !~ /<(img|br|hr|input|source|meta|link|area|base|col|embed|param|track|wbr)([ \t>\/])/ && line !~ /<https?:\/\// { |
There was a problem hiding this comment.
nit: the safe-list is HTML void elements only, but valid non-void containers like <details>, <summary>, <kbd>, <sub>, <sup> will get flagged if anyone uses them outside backticks. MDX accepts those fine. Quick repro:
$ echo '<details>' > t.md && bash tools/check-docs-mdx /path/with/t.md
MDX: bare <word> tag outside code fence: ...:1: <details>
No doc currently triggers this (the one <details> reference in docs/contributor/maintaining.md:99 is inside backticks), so this is latent. Worth keeping in mind if someone later adds a collapsible <details> block — they'll get flagged and may not realize the fix is to escape with <...> or wrap in backticks.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/contributor/validator.md`:
- Around line 215-216: The new section uses the acronyms "CI" and "OCI" without
defining them; update the first occurrence(s) (for example in the heading or
opening sentence around "What CI publishes:") to expand them like "continuous
integration (CI)" and "Open Container Initiative (OCI)" so both acronyms are
defined on first use (also apply the same expansion where CI/OCI first appear
later in the doc).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 32c90752-5fd2-43a3-baaf-d20380a43654
📒 Files selected for processing (1)
docs/contributor/validator.md
The bare <word> tag check added in #1170 reads files line-by-line and strips paired backticks within a single line. A multi-line code span that wrapped `--set-json gpu-operator:nodeSelector=<object>` across two lines left `<object>` outside the stripped backtick span on the second line, where MDX would parse it as a JSX component tag. Rewrap so the code span sits on one line. Pure text reflow; no anchor or link changes.
Summary
Add a bare
<word>angle-bracket check (check 5) totools/check-docs-mdxand fix two cross-line inline code spans that escaped detection.Motivation / Context
Fern's MDX parser interprets bare
<word>placeholders as JSX component tags and fails with parse errors. The existing MDX safety script had no check for this pattern class.Fixes: #1147
Related: #1151
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/server)pkg/recipe)pkg/bundler,pkg/component/*)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)tools/check-docs-mdxImplementation Notes
<[a-zA-Z]after stripping inline code and backslash-escaped patterns (\<word\>), excluding void HTML elements (check 1) and autolinks (check 4).validator.mdandcollector.mdwere collapsed to single-line spans so the per-linegsubstripper correctly excludes them.Testing
bash tools/check-docs-mdx # OK: all doc files are MDX-safe<placeholder>correctly flagged\<escaped\>patterns not flaggedRisk Assessment
Rollout notes: N/A
Checklist
make testwith-race)make lint)git commit -S) — GPG signing info