X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki.hs;h=719ed62cc646699ebb4069a2bc1c6b51506b3de0;hb=e43bb104a7313dd696b8bb8aa3bafff94706a187;hp=c5c2c68ec1b12b19e62bb73b85b81a5f96bc3ca2;hpb=1647278f9393f7382b6e8b8a5e9e14ce50aae718;p=Rakka.git diff --git a/Rakka/Wiki.hs b/Rakka/Wiki.hs index c5c2c68..719ed62 100644 --- a/Rakka/Wiki.hs +++ b/Rakka/Wiki.hs @@ -1,21 +1,38 @@ module Rakka.Wiki ( WikiPage - , WikiElement(..) + + , Element(..) + , Attribute + , BlockElement(..) , InlineElement(..) + + , Definition(..) + + , ListType(..) + , ListItem + + , CommandType(..) + , BlockCommand(..) + , InlineCommand(..) ) where +import Data.Generics +import Network.URI import Rakka.Page -type WikiPage = [WikiElement] +type WikiPage = [BlockElement] -data WikiElement - = Block !BlockElement +data Element + = Block !BlockElement | Inline !InlineElement - deriving (Eq, Show) + deriving (Eq, Show, Typeable, Data) + + +type Attribute = (String, String) data BlockElement @@ -23,15 +40,85 @@ data BlockElement headingLevel :: !Int , headingText :: !String } - | EmptyLine - deriving (Eq, Show) + | HorizontalLine + | List { + listType :: !ListType + , listItems :: ![ListItem] + } + | DefinitionList ![Definition] + | Preformatted ![InlineElement] + | Paragraph ![InlineElement] + | Div ![Attribute] ![Element] + | EmptyBlock + | BlockCmd !BlockCommand + deriving (Eq, Show, Typeable, Data) data InlineElement = Text !String + | Italic ![InlineElement] + | Bold ![InlineElement] + | ObjectLink { + objLinkPage :: !PageName + , objLinkText :: !(Maybe String) + } | PageLink { linkPage :: !(Maybe PageName) , linkFragment :: !(Maybe String) , linkText :: !(Maybe String) } + | ExternalLink { + extLinkURI :: !URI + , extLinkText :: !(Maybe String) + } + | LineBreak ![Attribute] + | Span ![Attribute] ![InlineElement] + | Image { + imgSource :: !PageName + , imgAlt :: !(Maybe String) + } + | Anchor ![Attribute] ![InlineElement] + | EmptyInline + | InlineCmd !InlineCommand + deriving (Eq, Show, Typeable, Data) + + +data ListType + = Bullet + | Numbered + deriving (Eq, Show, Typeable, Data) + + +type ListItem = [Element] + + +data Definition + = Definition { + defTerm :: ![InlineElement] + , defDesc :: ![InlineElement] + } + deriving (Eq, Show, Typeable, Data) + + +data CommandType + = InlineCommandType + | BlockCommandType deriving (Eq, Show) + + +data BlockCommand + = BlockCommand { + bCmdName :: !String + , bCmdAttributes :: ![Attribute] + , bCmdContents :: ![BlockElement] + } + deriving (Eq, Show, Typeable, Data) + + +data InlineCommand + = InlineCommand { + iCmdName :: !String + , iCmdAttributes :: ![Attribute] + , iCmdContents :: ![InlineElement] + } + deriving (Eq, Show, Typeable, Data)