git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: escape definition list terms starting with list markers
commitf39931fd6c86a4bf7a651f9e2f5667bfad99bcca authorAlexander Krotov <ilabdsf@gmail.com> dateMon 16 Apr 2018, 11:40 (9 years ago) parent8ca012f
2 files changed+16−6
src/Text/Pandoc/Writers/Muse.hs+7−6 test/Tests/Writers/Muse.hs+9
src/Text/Pandoc/Writers/Muse.hs+7−6
@@ -101,7 +101,7 @@ writeMuse opts document =
101101 , envInsideBlock = False
102102 , envInlineStart = True
103103 , envInsideLinkDescription = False
104− , envAfterSpace = True
104+ , envAfterSpace = False
105105 , envOneLine = False
106106 }
107107
@@ -223,7 +223,7 @@ blockToMuse (DefinitionList items) = do
223223 => ([Inline], [[Block]])
224224 -> Muse m Doc
225225 definitionListItemToMuse (label, defs) = do
226− label' <- local (\env -> env { envOneLine = True }) $ inlineListToMuse' label
226+ label' <- local (\env -> env { envOneLine = True, envAfterSpace = True }) $ inlineListToMuse' label
227227 contents <- vcat <$> mapM descriptionToMuse defs
228228 let ind = offset label'
229229 return $ hang ind label' contents
@@ -439,14 +439,15 @@ renderInlineList (x:xs) = do
439439
440440-- | Normalize and convert list of Pandoc inline elements to Muse.
441441inlineListToMuse'' :: PandocMonad m
442− => Bool
443− -> [Inline]
444− -> Muse m Doc
442+ => Bool
443+ -> [Inline]
444+ -> Muse m Doc
445445inlineListToMuse'' start lst = do
446446 lst' <- (normalizeInlineList . fixNotes) <$> preprocessInlineList (map (removeKeyValues . replaceSmallCaps) lst)
447447 topLevel <- asks envTopLevel
448+ afterSpace <- asks envAfterSpace
448449 local (\env -> env { envInlineStart = start
449− , envAfterSpace = start && not topLevel
450+ , envAfterSpace = afterSpace || (start && not topLevel)
450451 }) $ renderInlineList lst'
451452
452453inlineListToMuse' :: PandocMonad m => [Inline] -> Muse m Doc
test/Tests/Writers/Muse.hs+9
@@ -121,6 +121,15 @@ tests = [ testGroup "block elements"
121121 , " <verbatim></verbatim> foo :: second description"
122122 , " <verbatim></verbatim> > bar :: third description"
123123 ]
124+ , "definition list terms starting with list markers" =:
125+ definitionList [ (text "first definition", [plain $ text "first description"])
126+ , (str "-", [plain $ text "second description"])
127+ , (str "1.", [plain $ text "third description"])
128+ ]
129+ =?> unlines [ " first definition :: first description"
130+ , " <verbatim></verbatim>- :: second description"
131+ , " <verbatim></verbatim>1. :: third description"
132+ ]
124133 ]
125134 -- Test that lists of the same type and style are separated with two blanklines
126135 , testGroup "sequential lists"