Safe HaskellSafe-Infered

PPHtml

Description

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"]
             ]
       ]

Synopsis

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.

Constructors

HTML 

Fields

rows :: [TRow]
 

Instances

Eq HTML 
Show HTML 

data TRow

The way we represent a row in the HTML Table

Constructors

TRow 

Fields

columns :: [TCol]
 
rowtype :: String
 
shorthand :: String
 
ident :: String
 

Instances

Eq TRow 
Show TRow 

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!

Constructors

TCol 

Fields

parenttype :: String
 
key :: String
 
value :: String
 

Instances

Eq TCol 
Ord TCol

Instance for Ord to allow sorting the list of columns Author < Editor < Title < ...

Show 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

h2Doc :: HTML -> Feedback Doc

Prints the complete HTML document using the given Table body.

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

prLink :: TRow -> Feedback Doc

Produce the links that will allow the user to jump quickly to a certain entry for the given row

prAnchor :: TRow -> Feedback Doc

Produce the hidden anchor to jump to for an entry link