X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Flwn-epub.git;a=blobdiff_plain;f=src%2FLWN%2FArticle.hs;h=70c68a5190d724fc2663531c57a63d02efb7c227;hp=2820d54f93393a94fbd59b6928405c34f9598af1;hb=6103dbc5f8d3689e32001c3fd7627f3153e40bb0;hpb=5cb0170a5ab418147e3403fb141797f2282b78f4 diff --git a/src/LWN/Article.hs b/src/LWN/Article.hs index 2820d54..70c68a5 100644 --- a/src/LWN/Article.hs +++ b/src/LWN/Article.hs @@ -3,12 +3,36 @@ where import XHTML -data Article = Article { title :: String, - byline :: String, - body_html :: String } +newtype Title = Title { getTitle :: String } +newtype Byline = Byline { getByline :: Maybe String } +newtype BodyHtml = BodyHtml { getBodyHtml :: String } + +instance Show Title where + show = getTitle + +instance Show Byline where + show (Byline (Just bl)) = bl + show (Byline Nothing ) = "" + +instance Show BodyHtml where + show = getBodyHtml + +instance XHTML Title where + to_xhtml (Title t) = "

" ++ t ++ "

" + +instance XHTML Byline where + to_xhtml (Byline (Just bl)) = "

" ++ bl ++ "

" + to_xhtml (Byline Nothing) = "" + +instance XHTML BodyHtml where + to_xhtml = getBodyHtml + +data Article = Article { title :: Title, + byline :: Byline, + body_html :: BodyHtml } instance XHTML Article where to_xhtml (Article t bl b) = - "

" ++ t ++ "

\n\n" ++ - "

" ++ bl ++ "

\n\n" ++ - b + (to_xhtml t) ++ + (to_xhtml bl) ++ + (to_xhtml b)