Add Markdown footnotes#66
Conversation
|
Warning Review limit reached
More reviews will be available in 44 minutes and 56 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ 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.
Pull request overview
Adds a default-enabled Markdown footnotes feature to the rendering pipeline, allowing [^id] references and [^id]: ... definitions to be converted into linked endnotes while remaining configurable via site config.
Changes:
- Introduce
markdown.footnotesconfig option (defaulttrue) and parse it fromconfig.yaml. - Add footnote extraction + reference/list rendering around
md4c_toHtml()output. - Add unit tests and documentation updates; remove an obsolete Psalm baseline entry after tightening return types.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Render/MarkdownRenderer.php |
Implements conditional footnote processing and renders endnotes appended to HTML output. |
src/Content/Model/MarkdownConfig.php |
Adds footnotes boolean option (default-on) to the markdown config model. |
src/Content/Parser/SiteConfigParser.php |
Parses markdown.footnotes from configuration data into MarkdownConfig. |
tests/Unit/Render/MarkdownRendererTest.php |
Adds coverage for footnotes rendering, disabling behavior, and repeated references. |
tests/Unit/Content/MarkdownConfigTest.php |
Verifies default config and parser behavior for footnotes. |
docs/configuration.md |
Documents the new footnotes option and its default. |
psalm-baseline.xml |
Removes a baseline entry no longer needed due to explicit string casting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $html = $this->toHtml($markdown); | ||
| foreach ($references as $reference => $data) { | ||
| $id = $data['id']; | ||
| $number = $data['number']; | ||
| $escapedId = htmlspecialchars($id, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); | ||
| $escapedReferenceId = $this->referenceId($id, $reference); | ||
| $html = str_replace( | ||
| "\x1FFOOTNOTE_REF:" . $reference . "\x1F", | ||
| '<sup id="' . $escapedReferenceId . '" class="footnote-ref"><a href="#fn-' . $escapedId . '">' . $number . '</a></sup>', | ||
| $html, | ||
| ); | ||
| } |
| [$markdown, $definitions] = $this->extractFootnotes($markdown); | ||
| if ($definitions === []) { | ||
| return $this->toHtml($markdown); | ||
| } |
| public function testRendersRepeatedFootnoteReferencesWithUniqueReferenceIds(): void | ||
| { | ||
| $markdown = "First.[^note]\n\nSecond.[^note]\n\n[^note]: Footnote text."; | ||
| $html = $this->renderer->render($markdown); | ||
|
|
||
| assertStringContainsString('<sup id="fnref-note" class="footnote-ref"><a href="#fn-note">1</a></sup>', $html); | ||
| assertStringContainsString('<sup id="fnref-note-2" class="footnote-ref"><a href="#fn-note">1</a></sup>', $html); | ||
| assertStringContainsString('<li id="fn-note">Footnote text. <a href="#fnref-note" class="footnote-backref" aria-label="Back to reference">Back</a></li>', $html); | ||
| } |
Summary
Tests