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.
This commit is contained in:
John MacFarlane
2025-04-18 10:46:57 -07:00
parent 48f881d746
commit ec08f03782
2 changed files with 24 additions and 9 deletions
+10 -9
View File
@@ -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
+14
View File
@@ -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>
```