git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: support definitions with multiple descriptions

Muse reader does not support this syntax yet, but Emacs Muse parses it correctly.

commit01499b766b16f4ab1c7ce4e3e82780a099c6dd37 authorAlexander Krotov <ilabdsf@gmail.com> dateFri 19 Jan 2018, 14:58 (9 years ago) parent7680e9b
3 files changed+23−14
src/Text/Pandoc/Writers/Muse.hs+7−4 test/Tests/Writers/Muse.hs+11−2 test/writer.muse+5−8
src/Text/Pandoc/Writers/Muse.hs+7−4
@@ -212,10 +212,13 @@ blockToMuse (DefinitionList items) = do
212212 -> StateT WriterState m Doc
213213 definitionListItemToMuse (label, defs) = do
214214 label' <- inlineListToMuse label
215− contents <- liftM vcat $ mapM blockListToMuse defs
216− let label'' = label' <> " :: "
217− let ind = offset label''
218− return $ hang ind label'' contents
215+ contents <- liftM vcat $ mapM descriptionToMuse defs
216+ let ind = offset label'
217+ return $ hang ind label' contents
218+ descriptionToMuse :: PandocMonad m
219+ => [Block]
220+ -> StateT WriterState m Doc
221+ descriptionToMuse desc = (hang 4 " :: ") <$> blockListToMuse desc
219222blockToMuse (Header level (ident,_,_) inlines) = do
220223 opts <- gets stOptions
221224 contents <- inlineListToMuse inlines
test/Tests/Writers/Muse.hs+11−2
@@ -94,6 +94,15 @@ tests = [ testGroup "block elements"
9494 , " second definition :: second description"
9595 , " third definition :: third description"
9696 ]
97+ , "definition list with multiple descriptions" =:
98+ definitionList [ (text "first definition", [plain $ text "first description"
99+ ,plain $ text "second description"])
100+ , (text "second definition", [plain $ text "third description"])
101+ ]
102+ =?> unlines [ " first definition :: first description"
103+ , " :: second description"
104+ , " second definition :: third description"
105+ ]
97106 ]
98107 -- Test that lists of the same type and style are separated with two blanklines
99108 , testGroup "sequential lists"
@@ -197,8 +206,8 @@ tests = [ testGroup "block elements"
197206 ]
198207 , "nested definition lists" =: definitionList [ (text "first definition", [plain $ text "first description"])
199208 , (text "second definition",
200− [ plain (text "second description")
201− , definitionList [ ( text "first inner definition"
209+ [ plain (text "second description") <>
210+ definitionList [ ( text "first inner definition"
202211 , [plain $ text "first inner description"])
203212 , ( text "second inner definition"
204213 , [plain $ text "second inner description"])
test/writer.muse+5−8
@@ -287,24 +287,21 @@ Multiple blocks with italics:
287287Multiple definitions, tight:
288288
289289 apple :: red fruit
290− computer
290+ :: computer
291291 orange :: orange fruit
292− bank
292+ :: bank
293293
294294Multiple definitions, loose:
295295
296296 apple :: red fruit
297−
298− computer
297+ :: computer
299298 orange :: orange fruit
300−
301− bank
299+ :: bank
302300
303301Blank line after term, indented marker, alternate markers:
304302
305303 apple :: red fruit
306−
307− computer
304+ :: computer
308305 orange :: orange fruit
309306
310307 1. sublist