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 + diff --git a/test/docbook-reader.docbook b/test/docbook-reader.docbook index 8b0b34c42..f668279ca 100644 --- a/test/docbook-reader.docbook +++ b/test/docbook-reader.docbook @@ -194,9 +194,9 @@ These should not be escaped: \$ \\ \> \[ \{ </listitem> </itemizedlist> <para> - Pluses loose: + Asterisks tight: </para> - <itemizedlist> + <itemizedlist spacing="compact"> <listitem> <para> Plus 1 @@ -213,26 +213,6 @@ These should not be escaped: \$ \\ \> \[ \{ </para> </listitem> </itemizedlist> - <para> - Minuses loose: - </para> - <itemizedlist> - <listitem> - <para> - Minus 1 - </para> - </listitem> - <listitem> - <para> - Minus 2 - </para> - </listitem> - <listitem> - <para> - Minus 3 - </para> - </listitem> - </itemizedlist> </sect2> <sect2 id="ordered"> <title>Ordered</title> @@ -254,9 +234,9 @@ These should not be escaped: \$ \\ \> \[ \{ </listitem> </orderedlist> <para> - and using spaces: + and tight: </para> - <orderedlist numeration="arabic"> + <orderedlist spacing="compact" numeration="arabic"> <listitem> <para> One diff --git a/test/docbook-reader.native b/test/docbook-reader.native index 16eef6632..cad1d17a7 100644 --- a/test/docbook-reader.native +++ b/test/docbook-reader.native @@ -336,17 +336,11 @@ Pandoc , [ Para [ Str "asterisk" , Space , Str "2" ] ] , [ Para [ Str "asterisk" , Space , Str "3" ] ] ] - , Para [ Str "Pluses" , Space , Str "loose:" ] + , Para [ Str "Asterisks" , Space , Str "tight:" ] , BulletList - [ [ Para [ Str "Plus" , Space , Str "1" ] ] - , [ Para [ Str "Plus" , Space , Str "2" ] ] - , [ Para [ Str "Plus" , Space , Str "3" ] ] - ] - , Para [ Str "Minuses" , Space , Str "loose:" ] - , BulletList - [ [ Para [ Str "Minus" , Space , Str "1" ] ] - , [ Para [ Str "Minus" , Space , Str "2" ] ] - , [ Para [ Str "Minus" , Space , Str "3" ] ] + [ [ Plain [ Str "Plus" , Space , Str "1" ] ] + , [ Plain [ Str "Plus" , Space , Str "2" ] ] + , [ Plain [ Str "Plus" , Space , Str "3" ] ] ] , Header 2 ( "ordered" , [] , [] ) [ Str "Ordered" ] , OrderedList @@ -355,13 +349,12 @@ Pandoc , [ Para [ Str "Second" ] ] , [ Para [ Str "Third" ] ] ] - , Para - [ Str "and" , Space , Str "using" , Space , Str "spaces:" ] + , Para [ Str "and" , Space , Str "tight:" ] , OrderedList ( 1 , Decimal , DefaultDelim ) - [ [ Para [ Str "One" ] ] - , [ Para [ Str "Two" ] ] - , [ Para [ Str "Three" ] ] + [ [ Plain [ Str "One" ] ] + , [ Plain [ Str "Two" ] ] + , [ Plain [ Str "Three" ] ] ] , Para [ Str "Multiple" , Space , Str "paragraphs:" ] , OrderedList