Skip to content

Add Markdown footnotes#66

Open
samdark wants to merge 1 commit into
masterfrom
add-markdown-footnotes
Open

Add Markdown footnotes#66
samdark wants to merge 1 commit into
masterfrom
add-markdown-footnotes

Conversation

@samdark

@samdark samdark commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

  • add a default-on markdown.footnotes config option
  • render [^id] references and [^id]: definitions around md4c output
  • document the option and cover config/rendering behavior with tests

Tests

  • make test -- --filter MarkdownRendererTest
  • make test -- --filter MarkdownConfigTest
  • make psalm
  • make test

Copilot AI review requested due to automatic review settings June 13, 2026 08:57
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@samdark, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b74ff91-eea2-46bd-b8f5-433efa4d54f5

📥 Commits

Reviewing files that changed from the base of the PR and between 315ad8d and f21e9aa.

📒 Files selected for processing (7)
  • docs/configuration.md
  • psalm-baseline.xml
  • src/Content/Model/MarkdownConfig.php
  • src/Content/Parser/SiteConfigParser.php
  • src/Render/MarkdownRenderer.php
  • tests/Unit/Content/MarkdownConfigTest.php
  • tests/Unit/Render/MarkdownRendererTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-markdown-footnotes

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.footnotes config option (default true) and parse it from config.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.

Comment on lines +107 to +118
$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,
);
}
Comment on lines +81 to +84
[$markdown, $definitions] = $this->extractFootnotes($markdown);
if ($definitions === []) {
return $this->toHtml($markdown);
}
Comment on lines +115 to 123
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);
}
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.

2 participants