Muse writer: support definitions with multiple descriptions

Muse reader does not support this syntax yet, but Emacs Muse parses
it correctly.
This commit is contained in:
Alexander Krotov 2018-01-19 14:58:15 +03:00
parent 7680e9b964
commit 01499b766b
3 changed files with 23 additions and 14 deletions

View file

@ -212,10 +212,13 @@ blockToMuse (DefinitionList items) = do
-> StateT WriterState m Doc
definitionListItemToMuse (label, defs) = do
label' <- inlineListToMuse label
contents <- liftM vcat $ mapM blockListToMuse defs
let label'' = label' <> " :: "
let ind = offset label''
return $ hang ind label'' contents
contents <- liftM vcat $ mapM descriptionToMuse defs
let ind = offset label'
return $ hang ind label' contents
descriptionToMuse :: PandocMonad m
=> [Block]
-> StateT WriterState m Doc
descriptionToMuse desc = (hang 4 " :: ") <$> blockListToMuse desc
blockToMuse (Header level (ident,_,_) inlines) = do
opts <- gets stOptions
contents <- inlineListToMuse inlines

View file

@ -94,6 +94,15 @@ tests = [ testGroup "block elements"
, " second definition :: second description"
, " third definition :: third description"
]
, "definition list with multiple descriptions" =:
definitionList [ (text "first definition", [plain $ text "first description"
,plain $ text "second description"])
, (text "second definition", [plain $ text "third description"])
]
=?> unlines [ " first definition :: first description"
, " :: second description"
, " second definition :: third description"
]
]
-- Test that lists of the same type and style are separated with two blanklines
, testGroup "sequential lists"
@ -197,8 +206,8 @@ tests = [ testGroup "block elements"
]
, "nested definition lists" =: definitionList [ (text "first definition", [plain $ text "first description"])
, (text "second definition",
[ plain (text "second description")
, definitionList [ ( text "first inner definition"
[ plain (text "second description") <>
definitionList [ ( text "first inner definition"
, [plain $ text "first inner description"])
, ( text "second inner definition"
, [plain $ text "second inner description"])

View file

@ -287,24 +287,21 @@ Multiple blocks with italics:
Multiple definitions, tight:
apple :: red fruit
computer
:: computer
orange :: orange fruit
bank
:: bank
Multiple definitions, loose:
apple :: red fruit
computer
:: computer
orange :: orange fruit
bank
:: bank
Blank line after term, indented marker, alternate markers:
apple :: red fruit
computer
:: computer
orange :: orange fruit
1. sublist