Skip to content

Add InlineFootnotesExtension for inline footnotes#90

Draft
dereuromark wants to merge 3 commits intomasterfrom
feature/inline-footnotes
Draft

Add InlineFootnotesExtension for inline footnotes#90
dereuromark wants to merge 3 commits intomasterfrom
feature/inline-footnotes

Conversation

@dereuromark
Copy link
Contributor

Summary

  • Add InlineFootnotesExtension that converts [content]{.fn} spans to inline footnotes
  • Add registerInlineFootnote() method to HtmlRenderer for extension use
  • Inline footnotes integrate seamlessly with regular footnotes (shared numbering)
  • Supports full inline formatting in footnote content
  • Comprehensive test coverage (13 tests)

Usage

$converter = new DjotConverter();
$converter->addExtension(new InlineFootnotesExtension());

$html = $converter->convert('Text[An inline footnote]{.fn} here.');

Why This Syntax?

This follows the approach discussed in jgm/djot#286. Pandoc's ^[...] syntax conflicts with djot's superscript ^text^, so the span-with-class approach provides inline footnotes without parser changes.

Edge Cases Tested

  • Multiple inline footnotes
  • Mixed inline + regular footnotes
  • Formatting inside footnotes
  • Empty footnotes
  • Multiple classes including .fn
  • Numbering reset between renders
  • Backlink generation

Implements inline footnotes using span syntax: `[content]{.fn}`

This approach follows the discussion in jgm/djot#286, avoiding the
syntax conflict between Pandoc's `^[...]` and djot's superscript `^text^`.

Changes:
- Add `registerInlineFootnote()` method to HtmlRenderer for extension use
- Add `InlineFootnotesExtension` that converts `.fn` spans to footnotes
- Inline footnotes integrate seamlessly with regular footnotes
- Supports full inline formatting in footnote content
- Add comprehensive test coverage (13 tests)
- Document extension in extensions.md

Related: jgm/djot#286
@dereuromark dereuromark added the enhancement New feature or request label Mar 8, 2026
@codecov
Copy link

codecov bot commented Mar 8, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.51%. Comparing base (df215b7) to head (54b095d).

Files with missing lines Patch % Lines
src/Extension/InlineFootnotesExtension.php 92.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master      #90   +/-   ##
=========================================
  Coverage     93.50%   93.51%           
- Complexity     2302     2313   +11     
=========================================
  Files            78       79    +1     
  Lines          6070     6107   +37     
=========================================
+ Hits           5676     5711   +35     
- Misses          394      396    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant