git.iko.soy/typeable/pandoc
on master help sign in
Change 'HtmlEntities' module to 'Entities'. Adjusted calling

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

commitd4454536f021fc51b2a7211749560d97a1975de1 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 2 Jan 2007, 00:40 (20 years ago) parent4e57451
7 files changed+22−21
Pandoc.cabal.in+1−1 src/Main.hs+1 src/Text/Pandoc/HtmlEntities.hs → src/Text/Pandoc/Entities.hs+15−15 src/Text/Pandoc/Readers/HTML.hs+2−2 src/Text/Pandoc/Readers/Markdown.hs+1−1 src/Text/Pandoc/Shared.hs+1−1 src/Text/Pandoc/Writers/Docbook.hs+1−1
Pandoc.cabal.in+1−1
@@ -17,7 +17,7 @@ Extra-Source-Files: README COPYRIGHT man/man1/pandoc.1
1717Exposed-Modules: Text.ParserCombinators.Pandoc,
1818 Text.Pandoc.ASCIIMathML,
1919 Text.Pandoc.Definition,
20− Text.Pandoc.HtmlEntities,
20+ Text.Pandoc.Entities,
2121 Text.Pandoc.Shared,
2222 Text.Pandoc.UTF8,
2323 Text.Pandoc.Writers.DefaultHeaders,
src/Main.hs+1
@@ -336,6 +336,7 @@ defaultWriterName x =
336336 Just ["markdown"] -> "markdown"
337337 Just ["db"] -> "docbook"
338338 Just ["xml"] -> "docbook"
339+ Just ["sgml"] -> "docbook"
339340 Just _ -> "html"
340341
341342main = do
src/Text/Pandoc/HtmlEntities.hs → src/Text/Pandoc/Entities.hsrenamed+15−15
@@ -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 ("&quot;", chr 34),
8787 ("&amp;", chr 38),
8888 ("&lt;", chr 60),
src/Text/Pandoc/Readers/HTML.hs+2−2
@@ -45,7 +45,7 @@ import Text.ParserCombinators.Parsec
4545import Text.ParserCombinators.Pandoc
4646import Text.Pandoc.Definition
4747import Text.Pandoc.Shared
48−import Text.Pandoc.HtmlEntities ( decodeEntities, htmlEntityToChar )
48+import Text.Pandoc.Entities ( decodeEntities, entityToChar )
4949import Maybe ( fromMaybe )
5050import Char ( toUpper, toLower )
5151
@@ -397,7 +397,7 @@ entity = try (do
397397 num <- many1 digit
398398 return ("#" ++ num)))]
399399 char ';'
400− return (Str [fromMaybe '?' (htmlEntityToChar ("&" ++ body ++ ";"))]))
400+ return (Str [fromMaybe '?' (entityToChar ("&" ++ body ++ ";"))]))
401401
402402code = try (do
403403 htmlTag "code"
src/Text/Pandoc/Readers/Markdown.hs+1−1
@@ -41,7 +41,7 @@ import Text.Pandoc.Readers.HTML ( rawHtmlBlock,
4141 anyHtmlTag, anyHtmlEndTag,
4242 htmlEndTag, extractTagType,
4343 htmlBlockElement )
44−import Text.Pandoc.HtmlEntities ( decodeEntities )
44+import Text.Pandoc.Entities ( decodeEntities )
4545import Text.Regex ( matchRegex, mkRegex )
4646import Text.ParserCombinators.Parsec
4747
src/Text/Pandoc/Shared.hs+1−1
@@ -66,7 +66,7 @@ module Text.Pandoc.Shared (
6666 ) where
6767import Text.Pandoc.Definition
6868import Text.ParserCombinators.Parsec
69−import Text.Pandoc.HtmlEntities ( decodeEntities )
69+import Text.Pandoc.Entities ( decodeEntities )
7070import Text.Regex ( matchRegexAll, mkRegex, subRegex, Regex )
7171import Char ( toLower )
7272import List ( find, groupBy )
src/Text/Pandoc/Writers/Docbook.hs+1−1
@@ -33,7 +33,7 @@ module Text.Pandoc.Writers.Docbook (
3333import Text.Pandoc.Definition
3434import Text.Pandoc.Shared
3535import Text.Pandoc.Writers.HTML ( stringToSmartHtml, stringToHtml )
36−import Text.Pandoc.HtmlEntities ( encodeEntities )
36+import Text.Pandoc.Entities ( encodeEntities )
3737import Text.Html ( stringToHtmlString )
3838import Text.Regex ( mkRegex, matchRegex )
3939import Data.Char ( toLower, ord )