Safe Haskell | Safe-Infered |
---|
This model takes a string representation of an ATerm. This ATerm should be of the same form as example below.
example :: ATerm example = List $ [ Ann (Tuple [String "booklet", String "hoek123", String "avl01"]) [ Tuple [String "booktitle", String "de enige weg"] , Tuple [String "author", String "van Leeuwenhoek"] , Tuple [String "editor", String "Baantjer"] , Tuple [String "edition", String "2"] , Tuple [String "note", String "notitie"] ] ]
- main :: IO ()
- run :: IO ()
- data HTML = HTML {}
- data TRow = TRow {}
- data TCol = TCol {
- parenttype :: String
- key :: String
- value :: String
- example :: ATerm
- pphtml :: Component String String
- aterm2html :: Component ATerm HTML
- a2Html :: ATerm -> Feedback HTML
- a2Trow :: ATerm -> Feedback TRow
- a2String :: ATerm -> Feedback String
- a2Tcol :: String -> ATerm -> Feedback TCol
- html2string :: Component HTML String
- show' :: Doc -> String
- h2Doc :: HTML -> Feedback Doc
- prHtml :: Doc -> Doc -> Doc
- prHeader :: Doc
- prBody :: [TRow] -> Feedback Doc
- prMap :: (Doc -> Doc -> Doc) -> (a -> Feedback Doc) -> [a] -> Feedback Doc
- prMapV :: (a -> Feedback Doc) -> [a] -> Feedback Doc
- prMapH :: (a -> Feedback Doc) -> [a] -> Feedback Doc
- prTrow :: TRow -> Feedback Doc
- prTcol :: TCol -> Feedback Doc
- prLink :: TRow -> Feedback Doc
- prAnchor :: TRow -> Feedback Doc
Documentation
main :: IO ()
ioWrap the component of this module
run :: IO ()
Does the same as main, but returns extra errors and defining severity for warnings
data HTML
Our HTML datatype. It is only a list of rows. It actually does not represent HTML at all. Only the body of a HTML Table.
data TRow
The way we represent a row in the HTML Table
data TCol
The way we represent a cell in the HTML Table The parenttype has been added for sorting, TODO is it necessary? In other words: does the sorting depend on the parenttype? If not, why might not need the type of the row at all!
TCol | |
|
example :: ATerm
The example as defined above
pphtml :: Component String String
The main component which produces an ATerm from its input, translates it into HTML and then pretty prints the HTML
aterm2html :: Component ATerm HTML
Parse an ATerm representing HTML into our HTML datatype
a2Html :: ATerm -> Feedback HTML
Transforming an ATerm to HTML giving errors if the ATerm is not of the right form. The ATerm should be a List.
a2Trow :: ATerm -> Feedback TRow
Produce a TRow from an ATerm. The ATerm should be of the form:
Ann (Tuple [String <entrytype>, String <citationkey>, String \abbreviation\]) [<field>]
a2String :: ATerm -> Feedback String
Produce the (lower case) string that is represented by an ATerm String or give an error.
a2Tcol :: String -> ATerm -> Feedback TCol
Produces a TCol of the given input entrytype, expecting an ATerm Tuple of exactly two items.
html2string :: Component HTML String
Pretty printing of our HTML.
It uses the show instance for CCO.Printing.Doc we have defined below. All the functions defined below will give debugging information
show' :: Doc -> String
Show a Doc using only 80 columns, or fail if this is not possible
prHtml :: Doc -> Doc -> Doc
Given the way to print the start of the HTML file (header) and the way to print the table containing BibTex entries, prints the entire HTML file
prHeader :: Doc
Prints the header of the HTML file
prBody :: [TRow] -> Feedback Doc
Prints the HTML Table. It uses the higher order function prMap that prBody :: [TRow] -> Feedback Doc
prMap :: (Doc -> Doc -> Doc) -> (a -> Feedback Doc) -> [a] -> Feedback Doc
Maps a given printer (second argument) over a list (third argument)
and then concats
this list using a foldr and a given operator (first argument).
prMapV :: (a -> Feedback Doc) -> [a] -> Feedback Doc
Calls prMap with the vertical divider (>-<)
prMapH :: (a -> Feedback Doc) -> [a] -> Feedback Doc
Calls prMap with the horizontal divider (>#<). Using this is likely to break the `80' columns requirement from show'
prTrow :: TRow -> Feedback Doc
Pretty print a row by first adding an anchor and then adding all columns in sorted order
prTcol :: TCol -> Feedback Doc
Pretty print a cell. The default behaviour is to simply print the key, value pair with a colon in between Behaviour can be specialized by pattern matching on the key