fix handling of ordinals
authoradam <adam@megacz.com>
Thu, 10 Apr 2008 16:35:14 +0000 (09:35 -0700)
committeradam <adam@megacz.com>
Thu, 10 Apr 2008 16:35:14 +0000 (09:35 -0700)
darcs-hash:20080410163514-5007d-e76df2eae0616a49002cc6ad18c2453c0fee49ab.gz

src/Doc.lhs
src/Html.lhs

index 05ff37e..ab1418f 100644 (file)
@@ -118,7 +118,7 @@ unindent (Tree "I" indent _) v = unindent' ((length indent)+1) v
 
 instance FromTree [Text] where
   fromTree (Tree "Word"    chars       _) = [Chars              $ concatMap fromTree chars]
 
 instance FromTree [Text] where
   fromTree (Tree "Word"    chars       _) = [Chars              $ concatMap fromTree chars]
-  fromTree (Tree "Ordinal" x           _) = [Command "ordinal"  $ [Chars (show x)]]
+  fromTree (Tree "Ordinal" x           _) = [Command "ordinal"  $ [Chars $ concatMap show x]]
   fromTree (Tree "Fraction" [n,d]      _) = [Command "fraction" $ [(Chars (show n)), (Chars (show d))]]
   fromTree (Tree "WS"     _            _) = [WS]
   fromTree (Tree "Quotes" [x]          _) = [Quotes $ fromTree x]
   fromTree (Tree "Fraction" [n,d]      _) = [Command "fraction" $ [(Chars (show n)), (Chars (show d))]]
   fromTree (Tree "WS"     _            _) = [WS]
   fromTree (Tree "Quotes" [x]          _) = [Quotes $ fromTree x]
index 6fb939a..257079e 100644 (file)
@@ -246,7 +246,13 @@ instance ToHtml Text where
  toHtml (Command "br" _)          = "\n<br/>\n"
  toHtml (Command "cent" _)        = "&#189;"
  toHtml (Command "euro" _)        = "&#8364;"
  toHtml (Command "br" _)          = "\n<br/>\n"
  toHtml (Command "cent" _)        = "&#189;"
  toHtml (Command "euro" _)        = "&#8364;"
- toHtml (Command "ordinal" x)      = (toHtml x)++"<sup>"++"th"++"</sup>"
+
+ -- gross hack
+ toHtml (Command "ordinal" x) | (last (toHtml x) == '1') = (toHtml x)++"<sup>"++"st"++"</sup>"
+                              | (last (toHtml x) == '2') = (toHtml x)++"<sup>"++"nd"++"</sup>"
+                              | (last (toHtml x) == '3') = (toHtml x)++"<sup>"++"rd"++"</sup>"
+                              | otherwise                = (toHtml x)++"<sup>"++"th"++"</sup>"
+       
  -- FIXME: use "unicode vulgar fractions" here
  toHtml (Command "fraction" [n,d]) = "<sup>"++(toHtml n)++"</sup>"++"/"++"<sub>"++(toHtml d)++"</sub>"
  toHtml (Command "rfc" x)         = "<tt><a href=http://tools.ietf.org/html/rfc"++(toHtml x)++">RFC"++(toHtml x)++"</a></tt>"
  -- FIXME: use "unicode vulgar fractions" here
  toHtml (Command "fraction" [n,d]) = "<sup>"++(toHtml n)++"</sup>"++"/"++"<sub>"++(toHtml d)++"</sub>"
  toHtml (Command "rfc" x)         = "<tt><a href=http://tools.ietf.org/html/rfc"++(toHtml x)++">RFC"++(toHtml x)++"</a></tt>"