git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: escape definition list terms starting with list markers
f39931fAlexander Krotov
src/Text/Pandoc/Writers/Muse.hs+7−6
@@ -101,7 +101,7 @@ writeMuse opts document =
101 , envInsideBlock = False
101 , envInsideBlock = False
102 , envInlineStart = True
102 , envInlineStart = True
103 , envInsideLinkDescription = False
103 , envInsideLinkDescription = False
104− , envAfterSpace = True
104+ , envAfterSpace = False
105 , envOneLine = False
105 , envOneLine = False
106 }
106 }
107
107
@@ -223,7 +223,7 @@ blockToMuse (DefinitionList items) = do
223 => ([Inline], [[Block]])
223 => ([Inline], [[Block]])
224 -> Muse m Doc
224 -> Muse m Doc
225 definitionListItemToMuse (label, defs) = do
225 definitionListItemToMuse (label, defs) = do
226− label' <- local (\env -> env { envOneLine = True }) $ inlineListToMuse' label
226+ label' <- local (\env -> env { envOneLine = True, envAfterSpace = True }) $ inlineListToMuse' label
227 contents <- vcat <$> mapM descriptionToMuse defs
227 contents <- vcat <$> mapM descriptionToMuse defs
228 let ind = offset label'
228 let ind = offset label'
229 return $ hang ind label' contents
229 return $ hang ind label' contents
@@ -439,14 +439,15 @@ renderInlineList (x:xs) = do
439
439
440-- | Normalize and convert list of Pandoc inline elements to Muse.
440-- | Normalize and convert list of Pandoc inline elements to Muse.
441inlineListToMuse'' :: PandocMonad m
441inlineListToMuse'' :: PandocMonad m
442− => Bool
442+ => Bool
443− -> [Inline]
443+ -> [Inline]
444− -> Muse m Doc
444+ -> Muse m Doc
445inlineListToMuse'' start lst = do
445inlineListToMuse'' start lst = do
446 lst' <- (normalizeInlineList . fixNotes) <$> preprocessInlineList (map (removeKeyValues . replaceSmallCaps) lst)
446 lst' <- (normalizeInlineList . fixNotes) <$> preprocessInlineList (map (removeKeyValues . replaceSmallCaps) lst)
447 topLevel <- asks envTopLevel
447 topLevel <- asks envTopLevel
448+ afterSpace <- asks envAfterSpace
448 local (\env -> env { envInlineStart = start
449 local (\env -> env { envInlineStart = start
449− , envAfterSpace = start && not topLevel
450+ , envAfterSpace = afterSpace || (start && not topLevel)
450 }) $ renderInlineList lst'
451 }) $ renderInlineList lst'
451
452
452inlineListToMuse' :: PandocMonad m => [Inline] -> Muse m Doc
453inlineListToMuse' :: PandocMonad m => [Inline] -> Muse m Doc
test/Tests/Writers/Muse.hs+9
@@ -121,6 +121,15 @@ tests = [ testGroup "block elements"
121 , " <verbatim></verbatim> foo :: second description"
121 , " <verbatim></verbatim> foo :: second description"
122 , " <verbatim></verbatim> > bar :: third description"
122 , " <verbatim></verbatim> > bar :: third description"
123 ]
123 ]
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+ ]
124 ]
133 ]
125 -- Test that lists of the same type and style are separated with two blanklines
134 -- Test that lists of the same type and style are separated with two blanklines
126 , testGroup "sequential lists"
135 , testGroup "sequential lists"