Muse writer: indent lists inside <quote> with at least one space (#3795)

This commit is contained in:
Alexander Krotov 2017-07-12 18:16:02 +03:00 committed by John MacFarlane
parent e0025cf4f1
commit de117fbd9e
3 changed files with 25 additions and 7 deletions

View file

@ -102,6 +102,13 @@ pandocToMuse (Pandoc meta blocks) = do
Nothing -> return main
Just tpl -> renderTemplate' tpl context
-- | Convert list of Pandoc block elements to Muse
-- | without setting stTopLevel.
flatBlockListToMuse :: PandocMonad m
=> [Block] -- ^ List of block elements
-> StateT WriterState m Doc
flatBlockListToMuse blocks = cat <$> mapM blockToMuse blocks
-- | Convert list of Pandoc block elements to Muse.
blockListToMuse :: PandocMonad m
=> [Block] -- ^ List of block elements
@ -111,11 +118,11 @@ blockListToMuse blocks = do
modify $ \s -> s { stTopLevel = not $ stInsideBlock s
, stInsideBlock = True
}
contents <- mapM blockToMuse blocks
result <- flatBlockListToMuse blocks
modify $ \s -> s { stTopLevel = stTopLevel oldState
, stInsideBlock = stInsideBlock oldState
}
return $ cat contents
return result
-- | Convert Pandoc block element to Muse.
blockToMuse :: PandocMonad m
@ -141,10 +148,10 @@ blockToMuse (RawBlock (Format format) str) =
return $ blankline $$ "<literal style=\"" <> text format <> "\">" $$
text str $$ "</literal>" $$ blankline
blockToMuse (BlockQuote blocks) = do
contents <- blockListToMuse blocks
contents <- flatBlockListToMuse blocks
return $ blankline
<> "<quote>"
$$ flush contents -- flush to drop blanklines
$$ nest 0 contents -- nest 0 to remove trailing blank lines
$$ "</quote>"
<> blankline
blockToMuse (OrderedList (start, style, _) items) = do

View file

@ -137,6 +137,17 @@ tests = [ testGroup "block elements"
, " second inner definition :: second inner description"
]
]
-- Check that list is intended with one space even inside a quote
, "List inside block quote" =: blockQuote (orderedList [ plain $ text "first"
, plain $ text "second"
, plain $ text "third"
])
=?> unlines [ "<quote>"
, " 1. first"
, " 2. second"
, " 3. third"
, "</quote>"
]
]
, testGroup "headings"
[ "normal heading" =:

View file

@ -65,8 +65,8 @@ sub status {
A list:
1. item one
2. item two
1. item one
2. item two
Nested block quotes:
@ -281,7 +281,7 @@ Multiple blocks with italics:
</example>
<quote>
orange block quote
orange block quote
</quote>
Multiple definitions, tight: