diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-19 08:08:51 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-19 08:08:51 +0000 |
commit | 7d2c9c6fe6458a6b15fa63fe7ee0651a57e5ce32 (patch) | |
tree | d9f1d5b62d2313f9a0d085115df821f44d2e9b34 | |
parent | 94c6a1b250c812bd3f6d74332bd2f10b41623285 (diff) | |
download | pandoc-7d2c9c6fe6458a6b15fa63fe7ee0651a57e5ce32.tar.gz |
Added escapeCharAsString to Text.Pandoc.Shared.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@738 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index b8500ca7a..78206a7db 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -36,6 +36,7 @@ module Text.Pandoc.Shared ( joinWithSep, tabsToSpaces, backslashEscape, + escapeCharAsString, endsWith, stripTrailingNewlines, removeLeadingTrailingSpace, @@ -268,6 +269,14 @@ backslashEscape special (x:xs) = if x `elem` special then '\\':x:(backslashEscape special xs) else x:(backslashEscape special xs) +-- | Escape a character as a string +escapeCharAsString ch str "" = "" +escapeCharAsString ch str (x:xs) | x == ch = + str ++ escapeCharAsString ch str xs +escapeCharAsString ch str xs = + let (a,b) = break (== ch) xs in + a ++ escapeCharAsString ch str b + -- | Returns @True@ if string ends with given character. endsWith :: Char -> [Char] -> Bool endsWith char [] = False |