diff options
| author | John MacFarlane <[email protected]> | 2025-04-18 10:46:57 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-04-18 10:47:47 -0700 |
| commit | ec08f03782371b036416fbf4eede3002e000fff5 (patch) | |
| tree | 798268c829fce8754b0dc5003433290ded537b2e | |
| parent | 48f881d74620beddaa6f4c96c2239d179089b059 (diff) | |
OpenDocument writer: fix character styles in footnotes.
Character styles governing the position of the footnote
reference should not be imposed on the footnote text.
Closes #10791.
| -rw-r--r-- | src/Text/Pandoc/Writers/OpenDocument.hs | 19 | ||||
| -rw-r--r-- | test/command/10791.md | 14 |
2 files changed, 24 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 85df9c701..80fdb4177 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -115,10 +115,6 @@ addTextStyle :: PandocMonad m addTextStyle attrs i = modify $ \s -> s { stTextStyles = Map.insert attrs i (stTextStyles s) } -addTextStyleAttr :: PandocMonad m => TextStyle -> OD m () -addTextStyleAttr t = modify $ \s -> - s { stTextStyleAttr = Set.insert t (stTextStyleAttr s) } - increaseIndent :: PandocMonad m => OD m () increaseIndent = modify $ \s -> s { stIndentPara = 1 + stIndentPara s } @@ -150,14 +146,18 @@ inParagraphTagsWithStyle sty = inTags False "text:p" [("text:style-name", sty)] inSpanTags :: Text -> Doc Text -> Doc Text inSpanTags s = inTags False "text:span" [("text:style-name",s)] -withTextStyle :: PandocMonad m => TextStyle -> OD m a -> OD m a -withTextStyle s f = do +withAlteredTextStyles :: PandocMonad m + => (Set.Set TextStyle -> Set.Set TextStyle) -> OD m a -> OD m a +withAlteredTextStyles f action = do oldTextStyleAttr <- gets stTextStyleAttr - addTextStyleAttr s - res <- f + modify $ \st -> st{ stTextStyleAttr = f oldTextStyleAttr } + res <- action modify $ \st -> st{ stTextStyleAttr = oldTextStyleAttr } return res +withTextStyle :: PandocMonad m => TextStyle -> OD m a -> OD m a +withTextStyle s = withAlteredTextStyles (Set.insert s) + inTextStyle :: PandocMonad m => Doc Text -> OD m (Doc Text) inTextStyle d = do at <- gets stTextStyleAttr @@ -691,7 +691,8 @@ inlineToOpenDocument o ils , ("text:note-class", "footnote" )] $ inTagsSimple "text:note-citation" (text . show $ n + 1) <> inTagsSimple "text:note-body" t - nn <- footNote <$> withParagraphStyle o "Footnote" l + nn <- footNote <$> withAlteredTextStyles (const mempty) + (withParagraphStyle o "Footnote" l) addNote nn return nn diff --git a/test/command/10791.md b/test/command/10791.md new file mode 100644 index 000000000..e44878cb6 --- /dev/null +++ b/test/command/10791.md @@ -0,0 +1,14 @@ +``` +% pandoc -t opendocument +Aboard **the luxury cruise ship Heart of the Ocean[^1] in the Atlantic Ocean**... + +[^1]: **Heart of the Ocean** (海洋之心) – The Heart of the Ocean +^D +<text:p text:style-name="Text_20_body">Aboard +<text:span text:style-name="T1">the luxury cruise ship Heart of the +Ocean</text:span><text:note text:id="ftn0" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body><text:p text:style-name="Footnote"><text:span text:style-name="T1">Heart +of the Ocean</text:span> (海洋之心) – The Heart of the +Ocean</text:p></text:note-body></text:note><text:span text:style-name="T1"> +in the Atlantic Ocean</text:span>…</text:p> + +``` |
