Added escapeCharAsString to Text.Pandoc.Shared.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@738 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2007-07-19 08:08:51 +00:00
parent 94c6a1b250
commit 7d2c9c6fe6

View file

@ -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