Skip to content

Commit ec08f03

Browse files
committed
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.
1 parent 48f881d commit ec08f03

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/Text/Pandoc/Writers/OpenDocument.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ addTextStyle :: PandocMonad m
115115
addTextStyle attrs i = modify $ \s ->
116116
s { stTextStyles = Map.insert attrs i (stTextStyles s) }
117117

118-
addTextStyleAttr :: PandocMonad m => TextStyle -> OD m ()
119-
addTextStyleAttr t = modify $ \s ->
120-
s { stTextStyleAttr = Set.insert t (stTextStyleAttr s) }
121-
122118
increaseIndent :: PandocMonad m => OD m ()
123119
increaseIndent = modify $ \s -> s { stIndentPara = 1 + stIndentPara s }
124120

@@ -150,14 +146,18 @@ inParagraphTagsWithStyle sty = inTags False "text:p" [("text:style-name", sty)]
150146
inSpanTags :: Text -> Doc Text -> Doc Text
151147
inSpanTags s = inTags False "text:span" [("text:style-name",s)]
152148

153-
withTextStyle :: PandocMonad m => TextStyle -> OD m a -> OD m a
154-
withTextStyle s f = do
149+
withAlteredTextStyles :: PandocMonad m
150+
=> (Set.Set TextStyle -> Set.Set TextStyle) -> OD m a -> OD m a
151+
withAlteredTextStyles f action = do
155152
oldTextStyleAttr <- gets stTextStyleAttr
156-
addTextStyleAttr s
157-
res <- f
153+
modify $ \st -> st{ stTextStyleAttr = f oldTextStyleAttr }
154+
res <- action
158155
modify $ \st -> st{ stTextStyleAttr = oldTextStyleAttr }
159156
return res
160157

158+
withTextStyle :: PandocMonad m => TextStyle -> OD m a -> OD m a
159+
withTextStyle s = withAlteredTextStyles (Set.insert s)
160+
161161
inTextStyle :: PandocMonad m => Doc Text -> OD m (Doc Text)
162162
inTextStyle d = do
163163
at <- gets stTextStyleAttr
@@ -691,7 +691,8 @@ inlineToOpenDocument o ils
691691
, ("text:note-class", "footnote" )] $
692692
inTagsSimple "text:note-citation" (text . show $ n + 1) <>
693693
inTagsSimple "text:note-body" t
694-
nn <- footNote <$> withParagraphStyle o "Footnote" l
694+
nn <- footNote <$> withAlteredTextStyles (const mempty)
695+
(withParagraphStyle o "Footnote" l)
695696
addNote nn
696697
return nn
697698

test/command/10791.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
```
2+
% pandoc -t opendocument
3+
Aboard **the luxury cruise ship Heart of the Ocean[^1] in the Atlantic Ocean**...
4+
5+
[^1]: **Heart of the Ocean** (海洋之心) – The Heart of the Ocean
6+
^D
7+
<text:p text:style-name="Text_20_body">Aboard
8+
<text:span text:style-name="T1">the luxury cruise ship Heart of the
9+
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
10+
of the Ocean</text:span> (海洋之心) – The Heart of the
11+
Ocean</text:p></text:note-body></text:note><text:span text:style-name="T1">
12+
in the Atlantic Ocean</text:span>…</text:p>
13+
14+
```

0 commit comments

Comments
 (0)