[PR #1395] [MERGED] fix(epub): stop sidenote filter from injecting LaTeX into EPUB output #9067

Closed
opened 2026-05-03 01:17:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1395
Author: @octo-patch
Created: 4/18/2026
Status: Merged
Merged: 4/19/2026
Merged by: @profvjreddi

Base: devHead: fix/issue-1333-sidenote-epub-inline-rendering


📝 Commits (1)

  • 6b7a194 fix(epub): stop sidenote filter from injecting LaTeX into EPUB output

📊 Changes

1 file changed (+7 additions, -3 deletions)

View changed files

📝 book/quarto/filters/sidenote.lua (+7 -3)

📄 Description

Fixes #1333

Problem

The sidenote.lua filter matched on epub alongside latex/pdf:

if quarto.doc.is_format("latex") or quarto.doc.is_format("pdf") or quarto.doc.is_format("epub") then

Because ePub uses HTML internally, the pandoc.RawInline('latex', ...) nodes that wrap \sidenote{…} are silently dropped by the EPUB renderer. The footnote body (between the delimiters) is emitted inline, causing sidenote/footnote text to appear embedded in the running prose rather than as proper footnotes.

Example from the issue report: "1 milliwatt**The 1 mW Threshold**" — where The 1 mW Threshold is sidenote content that leaked into the main paragraph.

Solution

Remove epub from the format guard. For EPUB output, return nil lets Pandoc's default footnote renderer take over, placing footnote content correctly at the end of the chapter.

-- Before
if quarto.doc.is_format("latex") or quarto.doc.is_format("pdf") or quarto.doc.is_format("epub") then

-- After
if quarto.doc.is_format("latex") or quarto.doc.is_format("pdf") then

Testing

The fix can be verified by building the EPUB output and checking that footnotes no longer appear inline in the body text. The PDF/LaTeX sidenote behavior is unchanged.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1395 **Author:** [@octo-patch](https://github.com/octo-patch) **Created:** 4/18/2026 **Status:** ✅ Merged **Merged:** 4/19/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/issue-1333-sidenote-epub-inline-rendering` --- ### 📝 Commits (1) - [`6b7a194`](https://github.com/harvard-edge/cs249r_book/commit/6b7a1944664b865ee60ea22101ab9e35af4aef9a) fix(epub): stop sidenote filter from injecting LaTeX into EPUB output ### 📊 Changes **1 file changed** (+7 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `book/quarto/filters/sidenote.lua` (+7 -3) </details> ### 📄 Description Fixes #1333 ## Problem The `sidenote.lua` filter matched on `epub` alongside `latex`/`pdf`: ```lua if quarto.doc.is_format("latex") or quarto.doc.is_format("pdf") or quarto.doc.is_format("epub") then ``` Because ePub uses HTML internally, the `pandoc.RawInline('latex', ...)` nodes that wrap `\sidenote{…}` are silently dropped by the EPUB renderer. The footnote body (between the delimiters) is emitted inline, causing sidenote/footnote text to appear embedded in the running prose rather than as proper footnotes. Example from the issue report: `"1 milliwatt**The 1 mW Threshold**"` — where `The 1 mW Threshold` is sidenote content that leaked into the main paragraph. ## Solution Remove `epub` from the format guard. For EPUB output, `return nil` lets Pandoc's default footnote renderer take over, placing footnote content correctly at the end of the chapter. ```lua -- Before if quarto.doc.is_format("latex") or quarto.doc.is_format("pdf") or quarto.doc.is_format("epub") then -- After if quarto.doc.is_format("latex") or quarto.doc.is_format("pdf") then ``` ## Testing The fix can be verified by building the EPUB output and checking that footnotes no longer appear inline in the body text. The PDF/LaTeX sidenote behavior is unchanged. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-03 01:17:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#9067