@@ -59,8 +59,10 @@ module Text.Pandoc.Pretty (
63 , brackets
64 , brackets
@@ -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
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
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 '}')
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 ']')
413+-- | Puts a 'Doc' in parentheses.
415+parens = enclosed (char '[') (char ']')