aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-08-25 21:48:34 -0700
committerJohn MacFarlane <[email protected]>2023-08-25 21:48:34 -0700
commit5410514567721d0ee347d192bf3c6e4707739197 (patch)
tree5b2a903c15bf859478edaa819f8007c528030362 /src
parenta6fe02f46a93c8cfaad1a4cb3c5e166a7aea3a4b (diff)
Man writer: avoid a .PP right after a section heading.
This is at best a no-op (in groff man and mandoc) and at worst (in some formatters) may create extra whitespace. See #9020.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Man.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index fb05df1f7..6187232b3 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -254,7 +254,13 @@ blockListToMan :: PandocMonad m
-> [Block] -- ^ List of block elements
-> StateT WriterState m (Doc Text)
blockListToMan opts blocks =
- vcat <$> mapM (blockToMan opts) blocks
+ vcat <$> mapM (blockToMan opts) (go blocks)
+ where
+ -- Avoid .PP right after .SH; this is a no-op in groff man and mandoc
+ -- but may cause unwanted extra space in some renderers (see #9020)
+ go [] = []
+ go (h@Header{} : Para ils : rest) = h : Plain ils : go rest
+ go (x : xs) = x : go xs
-- | Convert list of Pandoc inline elements to man.
inlineListToMan :: PandocMonad m => WriterOptions -> [Inline] -> StateT WriterState m (Doc Text)