diff --git a/README.md b/README.md
index c98ed5a..4a366a0 100644
--- a/README.md
+++ b/README.md
@@ -175,6 +175,7 @@ Useful options:
--start-heading TEXT compile only content after an exact Markdown heading
--smart-quotes use typographic quotes in rendered text
--quote-inline-number-footnotes opt in to [11] notation inside [!QUOTE] blocks
+--quote-source-before-footnotes put a quotation's source above its local footnotes
--pdfa4 export verified PDF/A-4 (veraPDF required)
```
@@ -287,7 +288,7 @@ To preserve footnotes from the quoted source, define them inside the quotation.
> [!SOURCE] Author, *Work*
```
-Quote-local footnotes render inside the quotation after its text and before the right-aligned source attribution. Each `[!QUOTE]` has its own labels, so different quotations can each use footnote 17 with different definitions. An ordinary document footnote outside the quotation still uses `[^key]` and receives the document's sequential numbering.
+By default, quote-local footnotes render inside the quotation after its text and before the right-aligned source attribution. To place the source attribution immediately after the quotation text with its local footnotes underneath, check **Place quotation source attribution before its footnotes** under **Sections & TOC**, or use `--quote-source-before-footnotes` on the CLI. This optional layout works with both caret-prefixed and inline numbered quotation footnotes, and does not change ordinary document footnotes. Each `[!QUOTE]` has its own labels, so different quotations can each use footnote 17 with different definitions. An ordinary document footnote outside the quotation still uses `[^key]` and receives the document's sequential numbering.
**Optional inline numbered quotation footnotes:** Check **Enable inline numbered footnotes ([11]) in sourced blockquotes** under **Sections & TOC**, or pass `--quote-inline-number-footnotes` on the CLI. This allows copied source text of the form `[11]` and `[11]:` *only inside* a `[!QUOTE]` block, provided a matching local definition exists:
diff --git a/app.py b/app.py
index 2bd9e80..7fde2cb 100644
--- a/app.py
+++ b/app.py
@@ -468,6 +468,7 @@ def metadata_value(name: str) -> str | None:
keywords=metadata_value("keywords"),
smart_quotes=truthy("smart_quotes"),
quote_inline_number_footnotes=truthy("quote_inline_number_footnotes"),
+ quote_source_before_footnotes=truthy("quote_source_before_footnotes"),
emoji_style=emoji_style,
emoji_pack=emoji_pack,
underline_links=truthy("underline_links"),
diff --git a/pdf_compiler.py b/pdf_compiler.py
index ee7359b..7ddcb11 100644
--- a/pdf_compiler.py
+++ b/pdf_compiler.py
@@ -445,6 +445,7 @@ def __init__(
start_heading: str | None = None,
smart_quotes: bool = False,
quote_inline_number_footnotes: bool = False,
+ quote_source_before_footnotes: bool = False,
emoji_style: str = "twemoji",
emoji_pack: Path | None = None,
underline_links: bool = True,
@@ -459,6 +460,7 @@ def __init__(
self.author = author or ""
self.smart_quotes = smart_quotes
self.quote_inline_number_footnotes = quote_inline_number_footnotes
+ self.quote_source_before_footnotes = quote_source_before_footnotes
validate_emoji_style(emoji_style, emoji_pack)
self.emoji_style = emoji_style
self.emoji_pack = emoji_pack
@@ -803,11 +805,35 @@ def quotation_flowables(self, quote_lines: list[str]) -> list[RefParagraph]:
)
flowables.append(RefParagraph(body_text, body_style, body_refs))
+ def append_source(has_following: bool) -> None:
+ rendered_source, source_refs = self.quotation_inline(source, local_notes)
+ source_style = self.styles["QuotationSourceX"]
+ has_preceding = bool(flowables)
+ if has_preceding or has_following:
+ source_style = ParagraphStyle(
+ "QuotationSourceJoinedX",
+ parent=source_style,
+ quoteRoundTop=not has_preceding,
+ quoteRoundBottom=not has_following,
+ quotePaddingTop=0 if has_preceding else 6,
+ quotePaddingBottom=0 if has_following else 6,
+ spaceBefore=0,
+ spaceAfter=0,
+ )
+ flowables.append(
+ RefParagraph(f"— {rendered_source}", source_style, source_refs)
+ )
+
+ if source and self.quote_source_before_footnotes:
+ append_source(has_following=bool(local_note_items))
+
for index, (key, note_text) in enumerate(local_note_items):
rendered_note, note_refs = self.quotation_inline(note_text, local_notes)
note_style = self.styles["QuotationFootnoteX"]
has_preceding = bool(flowables)
- has_following = index < len(local_note_items) - 1 or bool(source)
+ has_following = index < len(local_note_items) - 1 or bool(
+ source and not self.quote_source_before_footnotes
+ )
if has_preceding or has_following:
note_style = ParagraphStyle(
f"QuotationFootnoteJoinedX{index}",
@@ -827,20 +853,8 @@ def quotation_flowables(self, quote_lines: list[str]) -> list[RefParagraph]:
)
)
- if source:
- rendered_source, source_refs = self.quotation_inline(source, local_notes)
- source_style = self.styles["QuotationSourceX"]
- if flowables:
- source_style = ParagraphStyle(
- "QuotationSourceJoinedX",
- parent=source_style,
- quoteRoundTop=False,
- quotePaddingTop=0,
- spaceBefore=0,
- )
- flowables.append(
- RefParagraph(f"— {rendered_source}", source_style, source_refs)
- )
+ if source and not self.quote_source_before_footnotes:
+ append_source(has_following=False)
if not flowables:
flowables.append(RefParagraph(" ", self.styles["QuotationBodyX"]))
@@ -1541,6 +1555,11 @@ def main() -> int:
action="store_true",
help="Interpret [11] citations and [11]: definitions inside [!QUOTE] blocks (off by default)",
)
+ parser.add_argument(
+ "--quote-source-before-footnotes",
+ action="store_true",
+ help="Place [!SOURCE] attribution before quote-local footnotes (off by default)",
+ )
args = parser.parse_args()
output = args.output or args.source.with_suffix(".pdf")
@@ -1567,6 +1586,7 @@ def main() -> int:
start_heading=args.start_heading,
smart_quotes=args.smart_quotes,
quote_inline_number_footnotes=args.quote_inline_number_footnotes,
+ quote_source_before_footnotes=args.quote_source_before_footnotes,
emoji_style=args.emoji_style,
emoji_pack=args.emoji_pack,
**presentation,
diff --git a/templates/index.html b/templates/index.html
index f7da588..2c3eb43 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -466,6 +466,9 @@
PDF Compiler
+
PDF outline/bookmarks are always generated from Markdown sections, even when the visible TOC is off or visible section numbering is disabled.