@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717-}
1818
1919{- |
20− Module : Text.Pandoc.HtmlEntities
20+ Module : Text.Pandoc.Entities
2121 Copyright : Copyright (C) 2006 John MacFarlane
2222 License : GNU GPL, version 2 or above
2323
@@ -25,12 +25,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2525 Stability : alpha
2626 Portability : portable
2727
28−Functions for encoding unicode characters as HTML entity references,
28+Functions for encoding unicode characters as entity references,
2929and vice versa.
3030-}
31−module Text.Pandoc.HtmlEntities (
32− htmlEntityToChar,
33− charToHtmlEntity,
31+module Text.Pandoc.Entities (
32+ entityToChar,
33+ charToEntity,
3434 decodeEntities,
3535 encodeEntities
3636 ) where
@@ -50,7 +50,7 @@ decodeEntities str =
5050 Nothing -> str
5151 Just (before, match, rest, _) -> before ++ replacement ++
5252 (decodeEntities rest)
53− where replacement = case (htmlEntityToChar match) of
53+ where replacement = case (entityToChar match) of
5454 Just ch -> [ch]
5555 Nothing -> match
5656
@@ -60,29 +60,29 @@ encodeEntities :: String -> String
6060encodeEntities [] = []
6161encodeEntities (c:cs) = if ord c < 127
6262 then c:(encodeEntities cs)
63− else (charToHtmlEntity c) ++ (encodeEntities cs)
63+ else (charToEntity c) ++ (encodeEntities cs)
6464
6565-- | If the string is a valid entity reference, returns @Just@ the character,
6666-- otherwise @Nothing@.
67−htmlEntityToChar :: String -> Maybe Char
68−htmlEntityToChar entity =
69− case (lookup entity htmlEntityTable) of
67+entityToChar :: String -> Maybe Char
68+entityToChar entity =
69+ case (lookup entity entityTable) of
7070 Just ch -> Just ch
7171 Nothing -> case (matchRegexAll decimalCodedEntity entity) of
7272 Just (_, _, _, [sub]) -> Just (chr (read sub))
7373 Nothing -> Nothing
7474
7575-- | Returns a string containing an entity reference for the character.
76−charToHtmlEntity :: Char -> String
77−charToHtmlEntity char =
76+charToEntity :: Char -> String
77+charToEntity char =
7878 let matches = filter (\(entity, character) -> (character == char))
79− htmlEntityTable in
79+ entityTable in
8080 if (length matches) == 0
8181 then "&#" ++ show (ord char) ++ ";"
8282 else fst (head matches)
8383
84−htmlEntityTable :: [(String, Char)]
85−htmlEntityTable = [
84+entityTable :: [(String, Char)]
85+entityTable = [
8686 (""", chr 34),
8787 ("&", chr 38),
8888 ("<", chr 60),