@@ -31,7 +31,7 @@ module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where
3131import Text.Pandoc.Definition
3232import Text.Pandoc.Shared
3333import Text.Printf ( printf )
34−import Data.List ( (\\), intersperse )
34+import Data.List ( (\\), intersperse, isSuffixOf )
3535import Control.Monad.State
3636import Text.PrettyPrint.HughesPJ hiding ( Str )
3737
@@ -292,7 +292,9 @@ inlineToConTeXt (Image alternate (src, tit)) = do
292292 text tit <> text "}\n{\\externalfigure[" <> text src <> text "]}"
293293inlineToConTeXt (Note contents) = do
294294 contents' <- blockListToConTeXt contents
295− return $ text " \\footnote{" <>
296− text (stripTrailingNewlines $ render contents') <>
297− char '}'
295+ let rawnote = stripTrailingNewlines $ render contents'
296+ -- note: a \n before } is needed when note ends with a \stoptyping
297+ let optNewline = "\\stoptyping" `isSuffixOf` rawnote
298+ return $ text "\\footnote{" <>
299+ text rawnote <> (if optNewline then char '\n' else empty) <> char '}'
298300