never executed always true always false
1 {-# LANGUAGE DeriveDataTypeable #-}
2 module Cheapskate.Types where
3 import Data.Sequence (Seq)
4 import Data.Text (Text)
5 import qualified Data.Map as M
6 import Data.Data
7
8 -- | Structured representation of a document. The 'Options' affect
9 -- how the document is rendered by `toHtml`.
10 data Doc = Doc Options Blocks
11 deriving (Show, Data, Typeable)
12
13 -- | Block-level elements.
14 data Block = Para Inlines
15 | Header Int Inlines
16 | Blockquote Blocks
17 | List Bool ListType [Blocks]
18 | CodeBlock CodeAttr Text
19 | HtmlBlock Text
20 | HRule
21 | ReferencesBlock [(Text, Text, Text)]
22 | ElmDocs [[Text]]
23 deriving (Show, Data, Typeable, Eq)
24
25 -- | Attributes for fenced code blocks. 'codeLang' is the
26 -- first word of the attribute line, 'codeInfo' is the rest.
27 data CodeAttr = CodeAttr { codeLang :: Text, codeInfo :: Text }
28 deriving (Show, Data, Typeable, Eq)
29
30 data ListType = Bullet Char | Numbered NumWrapper Int deriving (Eq,Show,Data,Typeable)
31 data NumWrapper = PeriodFollowing | ParenFollowing deriving (Eq,Show,Data,Typeable)
32
33 -- | Simple representation of HTML tag.
34 data HtmlTagType = Opening Text | Closing Text | SelfClosing Text deriving (Show, Data, Typeable)
35
36 -- We operate with sequences instead of lists, because
37 -- they allow more efficient appending on to the end.
38 type Blocks = Seq Block
39
40 -- | Inline elements.
41 data Inline = Str Text
42 | Space
43 | SoftBreak
44 | LineBreak
45 | Emph Inlines
46 | Strong Inlines
47 | Code Text
48 | Link Inlines LinkTarget {- URL -} Text {- title -}
49 | Image Inlines Text {- URL -} Text {- title -}
50 | Entity Text
51 | RawHtml Text
52 deriving (Show, Data, Typeable, Eq)
53
54
55 data LinkTarget
56 = Url Text
57 | Ref Text
58 deriving (Show, Data, Eq)
59
60
61 type Inlines = Seq Inline
62
63 type ReferenceMap = M.Map Text (Text, Text)
64
65 -- | Rendering and parsing options.
66 data Options = Options{
67 sanitize :: Bool -- ^ Sanitize raw HTML, link/image attributes
68 , allowRawHtml :: Bool -- ^ Allow raw HTML (if false it gets escaped)
69 , preserveHardBreaks :: Bool -- ^ Preserve hard line breaks in the source
70 , debug :: Bool -- ^ Print container structure for debugging
71 }
72 deriving (Show, Data, Typeable)