git.iko.soy/typeable/pandoc
on master help sign in
Pretty: Added enclosed, parens.
9120514John MacFarlane
src/Text/Pandoc/Pretty.hs+13−2
@@ -59,8 +59,10 @@ module Text.Pandoc.Pretty (
59 , hsep
59 , hsep
60 , vcat
60 , vcat
61 , vsep
61 , vsep
62+ , enclosed
62 , braces
63 , braces
63 , brackets
64 , brackets
65+ , parens
64 )
66 )
65
67
66where
68where
@@ -395,10 +397,19 @@ chop n cs = case break (=='\n') cs of
395 else take n xs : chop n (drop n xs ++ ys)
397 else take n xs : chop n (drop n xs ++ ys)
396 where len = length xs
398 where len = length xs
397
399
400+-- | Encloses a 'Doc' inside a start and end 'Doc'.
401+enclosed :: Doc -> Doc -> Doc -> Doc
402+enclosed start end contents =
403+ start <> contents <> end
404+
398-- | Puts a 'Doc' in curly braces.
405-- | Puts a 'Doc' in curly braces.
399braces :: Doc -> Doc
406braces :: Doc -> Doc
400−braces d = char '{' <> d <> char '}'
407+braces = enclosed (char '{') (char '}')
401
408
402-- | Puts a 'Doc' in square brackets.
409-- | Puts a 'Doc' in square brackets.
403brackets :: Doc -> Doc
410brackets :: Doc -> Doc
404−brackets d = char '[' <> d <> char ']'
411+brackets = enclosed (char '[') (char ']')
412+
413+-- | Puts a 'Doc' in parentheses.
414+parens :: Doc -> Doc
415+parens = enclosed (char '[') (char ']')