From d14dee0dc2dd8d0d929d695feee18588aa4707a9 Mon Sep 17 00:00:00 2001 From: Chris Callison-Burch Date: Wed, 14 Jan 2026 05:14:30 -0500 Subject: PPTX writer: support notes field in metadata for title slide (#11396) This adds support for a `notes` field in the YAML metadata block that will be used as speaker notes for the title slide in PowerPoint output. Previously, there was no way to add speaker notes to the title slide since it is generated from metadata rather than from content blocks. The `::: notes` syntax only works for content slides. Example usage: --- title: My Presentation notes: | Welcome everyone to this presentation. Remember to introduce yourself. --- Closes #5844 (for PPTX output). Co-authored-by: Chris Callison-Burch --- MANUAL.txt | 17 +++++++++++++++++ src/Text/Pandoc/Writers/Powerpoint/Presentation.hs | 8 +++++++- test/Tests/Writers/Powerpoint.hs | 4 ++++ test/pptx/metadata-speaker-notes/input.native | 3 +++ test/pptx/metadata-speaker-notes/output.pptx | Bin 0 -> 31689 bytes test/pptx/metadata-speaker-notes/templated.pptx | Bin 0 -> 44773 bytes 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/pptx/metadata-speaker-notes/input.native create mode 100644 test/pptx/metadata-speaker-notes/output.pptx create mode 100644 test/pptx/metadata-speaker-notes/templated.pptx diff --git a/MANUAL.txt b/MANUAL.txt index 28c6341d0..28d4aa160 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -6938,6 +6938,23 @@ in handouts and presenter view. Notes are not yet supported for other slide formats, but the notes will not appear on the slides themselves. +### Speaker notes on the title slide (PowerPoint) + +For PowerPoint output, the title slide is generated from the document's +YAML metadata block. To add speaker notes to this slide, use a `notes` +field in the metadata: + + --- + title: My Presentation + author: Jane Doe + notes: | + Welcome everyone to this presentation. + + Remember to introduce yourself and mention the key topics. + --- + +The `notes` field can contain multiple paragraphs and Markdown formatting. + ## Columns To put material in side by side columns, you can use a native diff --git a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs index 9e7bcb04f..b969c645b 100644 --- a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs +++ b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs @@ -887,6 +887,12 @@ getMetaSlide = do subtitle <- inlinesToParElems $ lookupMetaInlines "subtitle" meta authors <- mapM inlinesToParElems $ docAuthors meta date <- inlinesToParElems $ docDate meta + -- Get speaker notes from metadata "notes" field + let notesBlocks = lookupMetaBlocks "notes" meta + speakerNotes <- if null notesBlocks + then return mempty + else local (\env -> env{envInSpeakerNotes=True}) $ + SpeakerNotes . mconcat <$> mapM blockToParagraphs notesBlocks if null title && null subtitle && null authors && null date then return Nothing else return $ @@ -894,7 +900,7 @@ getMetaSlide = do Slide metadataSlideId (MetadataSlide title subtitle authors date) - mempty + speakerNotes Nothing addSpeakerNotesToMetaSlide :: Slide -> [Block] -> Pres (Slide, [Block]) diff --git a/test/Tests/Writers/Powerpoint.hs b/test/Tests/Writers/Powerpoint.hs index 35269205b..c8dc00e6e 100644 --- a/test/Tests/Writers/Powerpoint.hs +++ b/test/Tests/Writers/Powerpoint.hs @@ -126,6 +126,10 @@ tests = let def "pptx/speaker-notes-after-metadata/input.native" "pptx/speaker-notes-after-metadata/output.pptx" + , pptxTests "speaker notes from metadata field" + def + "pptx/metadata-speaker-notes/input.native" + "pptx/metadata-speaker-notes/output.pptx" , pptxTests "remove empty slides" def "pptx/remove-empty-slides/input.native" diff --git a/test/pptx/metadata-speaker-notes/input.native b/test/pptx/metadata-speaker-notes/input.native new file mode 100644 index 000000000..1b34755e0 --- /dev/null +++ b/test/pptx/metadata-speaker-notes/input.native @@ -0,0 +1,3 @@ +Pandoc (Meta {unMeta = fromList [("author",MetaInlines [Str "Jesse",Space,Str "Rosenthal"]),("notes",MetaBlocks [Para [Str "These",Space,Str "are",Space,Str "speaker",Space,Str "notes",Space,Str "from",Space,Str "metadata."]]),("title",MetaInlines [Str "Testing"])]}) +[Header 1 ("a-header",[],[]) [Str "A",Space,Str "header"] +,Para [Str "And",Space,Str "a",Space,Str "new",Space,Str "slide."]] diff --git a/test/pptx/metadata-speaker-notes/output.pptx b/test/pptx/metadata-speaker-notes/output.pptx new file mode 100644 index 000000000..8f46a780c Binary files /dev/null and b/test/pptx/metadata-speaker-notes/output.pptx differ diff --git a/test/pptx/metadata-speaker-notes/templated.pptx b/test/pptx/metadata-speaker-notes/templated.pptx new file mode 100644 index 000000000..3f78d6401 Binary files /dev/null and b/test/pptx/metadata-speaker-notes/templated.pptx differ -- cgit v1.2.3