aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-12-19 12:39:49 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2010-12-19 12:39:49 -0800
commit9120514998cabb9d53379acb289fa71ed55b3880 (patch)
tree4f536ca64c83200ce8e37a0c349426f071da5865 /src
parent59cc27c10bbb0b96bd45cd291ea3f56bbfd9049e (diff)
downloadpandoc-9120514998cabb9d53379acb289fa71ed55b3880.tar.gz
Pretty: Added enclosed, parens.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Pretty.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs
index 950d9a406..3ba5c4b2c 100644
--- a/src/Text/Pandoc/Pretty.hs
+++ b/src/Text/Pandoc/Pretty.hs
@@ -59,8 +59,10 @@ module Text.Pandoc.Pretty (
, hsep
, vcat
, vsep
+ , enclosed
, braces
, brackets
+ , parens
)
where
@@ -395,10 +397,19 @@ chop n cs = case break (=='\n') cs of
else take n xs : chop n (drop n xs ++ ys)
where len = length xs
+-- | Encloses a 'Doc' inside a start and end 'Doc'.
+enclosed :: Doc -> Doc -> Doc -> Doc
+enclosed start end contents =
+ start <> contents <> end
+
-- | Puts a 'Doc' in curly braces.
braces :: Doc -> Doc
-braces d = char '{' <> d <> char '}'
+braces = enclosed (char '{') (char '}')
-- | Puts a 'Doc' in square brackets.
brackets :: Doc -> Doc
-brackets d = char '[' <> d <> char ']'
+brackets = enclosed (char '[') (char ']')
+
+-- | Puts a 'Doc' in parentheses.
+parens :: Doc -> Doc
+parens = enclosed (char '[') (char ']')