@@ -59,8 +59,10 @@ module Text.Pandoc.Pretty (
5959 , hsep
6060 , vcat
6161 , vsep
62+ , enclosed
6263 , braces
6364 , brackets
65+ , parens
6466 )
6567
6668where
@@ -395,10 +397,19 @@ chop n cs = case break (=='\n') cs of
395397 else take n xs : chop n (drop n xs ++ ys)
396398 where len = length xs
397399
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+
398405-- | Puts a 'Doc' in curly braces.
399406braces :: Doc -> Doc
400−braces d = char '{' <> d <> char '}'
407+braces = enclosed (char '{') (char '}')
401408
402409-- | Puts a 'Doc' in square brackets.
403410brackets :: 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 ']')