git.iko.soy/typeable/pandoc
on master help sign in
Added support for hexadecimal entities: e.g. ꂫ

git-svn-id: https://pandoc.googlecode.com/svn/trunk@441 788f1e2b-df1e-0410-8736-df70ead52e1b

commit58dcef062556067b753892c8020d7f8c4e0bed0c authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 6 Jan 2007, 19:47 (20 years ago) parentcbfe29f
1 file changed+6−6
src/Text/Pandoc/Entities.hs+6−6
src/Text/Pandoc/Entities.hs+6−6
@@ -39,13 +39,13 @@ import Data.Char ( chr, ord )
3939import Text.Regex ( mkRegex, matchRegexAll, Regex )
4040import Maybe ( fromMaybe )
4141
42−-- | Regular expression for decimal coded entity.
43−decimalCodedEntity :: Text.Regex.Regex
44−decimalCodedEntity = mkRegex "&#([0-9]+);"
42+-- | Regular expression for numerical coded entity.
43+numericalEntity :: Text.Regex.Regex
44+numericalEntity = mkRegex "&#([0-9]+|[xX][0-9A-Fa-f]+);"
4545
4646-- | Regular expression for character entity.
4747characterEntity :: Text.Regex.Regex
48−characterEntity = mkRegex "&#[0-9]+;|&[A-Za-z0-9]+;"
48+characterEntity = mkRegex "&#[0-9]+;|&#[xX][0-9A-Fa-f]+;|&[A-Za-z0-9]+;"
4949
5050-- | Return a string with all entity references decoded to unicode characters
5151-- where possible.
@@ -73,8 +73,8 @@ entityToChar :: String -> Maybe Char
7373entityToChar entity =
7474 case (lookup entity entityTable) of
7575 Just ch -> Just ch
76− Nothing -> case (matchRegexAll decimalCodedEntity entity) of
77− Just (_, _, _, [sub]) -> Just (chr (read sub))
76+ Nothing -> case (matchRegexAll numericalEntity entity) of
77+ Just (_, _, _, [sub]) -> Just (chr (read ('0':sub)))
7878 Nothing -> Nothing
7979
8080-- | Returns a string containing an entity reference for the character.