aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-01-03 14:18:25 -0800
committerJohn MacFarlane <[email protected]>2022-01-03 14:19:53 -0800
commit53699f2ab3f9b6dce04ae44a0d0342cb78974bd1 (patch)
treee36bd25a9589ec696281a18f085fbb51ddb06761 /src
parentca7a3ed5ed31e0c5787926d7b775c8f57c5932a4 (diff)
DocBook reader: be sensitive to spacing="compact" in lists.
When spacing="compact" is set, Para elements are turned into Plain, so we get a "tight" list. Closes #7799.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index 36035ff72..a0801124f 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -843,7 +843,7 @@ parseBlock (Elem e) =
"answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
"abstract" -> blockQuote <$> getBlocks e
"calloutlist" -> bulletList <$> callouts
- "itemizedlist" -> bulletList <$> listitems
+ "itemizedlist" -> bulletList . handleCompact <$> listitems
"orderedlist" -> do
let listStyle = case attrValue "numeration" e of
"arabic" -> Decimal
@@ -855,7 +855,7 @@ parseBlock (Elem e) =
let start = fromMaybe 1 $
filterElement (named "listitem") e
>>= safeRead . attrValue "override"
- orderedListWith (start,listStyle,DefaultDelim)
+ orderedListWith (start,listStyle,DefaultDelim) . handleCompact
<$> listitems
"variablelist" -> definitionList <$> deflistitems
"procedure" -> bulletList <$> steps
@@ -903,6 +903,14 @@ parseBlock (Elem e) =
lift $ report $ IgnoredElement name
return mempty
+ compactSpacing = case attrValue "spacing" e of
+ "compact" -> True
+ _ -> False
+
+ handleCompact = if compactSpacing
+ then map (fmap paraToPlain)
+ else id
+
codeBlockWithLang = do
let classes' = case attrValue "language" e of
"" -> []
@@ -1320,3 +1328,8 @@ showVerbatimCData c = showContent c
-- | Set the prefix of a name to 'Nothing'
removePrefix :: QName -> QName
removePrefix elname = elname { qPrefix = Nothing }
+
+paraToPlain :: Block -> Block
+paraToPlain (Para ils) = Plain ils
+paraToPlain x = x
+