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.
This commit is contained in:
parent
ca7a3ed5ed
commit
53699f2ab3
3 changed files with 27 additions and 41 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue