diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-12-19 12:39:49 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-12-19 12:39:49 -0800 |
commit | 9120514998cabb9d53379acb289fa71ed55b3880 (patch) | |
tree | 4f536ca64c83200ce8e37a0c349426f071da5865 /src/Text/Pandoc | |
parent | 59cc27c10bbb0b96bd45cd291ea3f56bbfd9049e (diff) | |
download | pandoc-9120514998cabb9d53379acb289fa71ed55b3880.tar.gz |
Pretty: Added enclosed, parens.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Pretty.hs | 15 |
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 ']') |