From 89d45d9a43527a84134ad2fa133d86c3cd7eec07 Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 10 Apr 2008 09:35:14 -0700 Subject: [PATCH] fix handling of ordinals darcs-hash:20080410163514-5007d-e76df2eae0616a49002cc6ad18c2453c0fee49ab.gz --- src/Doc.lhs | 2 +- src/Html.lhs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Doc.lhs b/src/Doc.lhs index 05ff37e..ab1418f 100644 --- a/src/Doc.lhs +++ b/src/Doc.lhs @@ -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] - 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] diff --git a/src/Html.lhs b/src/Html.lhs index 6fb939a..257079e 100644 --- a/src/Html.lhs +++ b/src/Html.lhs @@ -246,7 +246,13 @@ instance ToHtml Text where toHtml (Command "br" _) = "\n
\n" toHtml (Command "cent" _) = "½" toHtml (Command "euro" _) = "€" - toHtml (Command "ordinal" x) = (toHtml x)++""++"th"++"" + + -- gross hack + toHtml (Command "ordinal" x) | (last (toHtml x) == '1') = (toHtml x)++""++"st"++"" + | (last (toHtml x) == '2') = (toHtml x)++""++"nd"++"" + | (last (toHtml x) == '3') = (toHtml x)++""++"rd"++"" + | otherwise = (toHtml x)++""++"th"++"" + -- FIXME: use "unicode vulgar fractions" here toHtml (Command "fraction" [n,d]) = ""++(toHtml n)++""++"/"++""++(toHtml d)++"" toHtml (Command "rfc" x) = "RFC"++(toHtml x)++"" -- 1.7.10.4