X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki.hs;h=bdecec7fac00a5da4b3aa5e86865bc6e2fc91955;hb=45bce2c29948649f74ada71f2fa851bdb812e96c;hp=96231a46c72174bc33c7df3733e8c9457e230b09;hpb=bd2b1344f5ed3d4de91297bfe08658e52d682b82;p=Rakka.git diff --git a/Rakka/Wiki.hs b/Rakka/Wiki.hs index 96231a4..bdecec7 100644 --- a/Rakka/Wiki.hs +++ b/Rakka/Wiki.hs @@ -1,107 +1,117 @@ +{-# LANGUAGE + UnicodeSyntax + #-} module Rakka.Wiki ( WikiPage + + , Element(..) + , Attribute + , BlockElement(..) , InlineElement(..) - , ListElement(..) + , Definition(..) + , ListType(..) , ListItem - , Definition(..) - , CommandType(..) - , Attribute , BlockCommand(..) , InlineCommand(..) ) where - -import Data.Generics -import Rakka.Page - +import Data.CaseInsensitive (CI) +import Data.Text (Text) +import Network.URI +import Rakka.Page type WikiPage = [BlockElement] +data Element + = Block !BlockElement + | Inline !InlineElement + deriving (Eq, Show) + +type Attribute = (CI Text, Text) data BlockElement = Heading { - headingLevel :: !Int - , headingText :: !String + headingLevel ∷ !Int + , headingText ∷ !Text } | HorizontalLine - | List !ListElement + | List { + listType ∷ !ListType + , listItems ∷ ![ListItem] + } | DefinitionList ![Definition] - | Preformatted ![InlineElement] - | Paragraph ![InlineElement] - | Div ![Attribute] ![BlockElement] - | BlockCmd !BlockCommand - deriving (Eq, Show, Typeable, Data) - + | Preformatted ![InlineElement] + | Paragraph ![InlineElement] + | Div ![Attribute] ![Element] + | EmptyBlock + | BlockCmd !BlockCommand + deriving (Eq, Show) data InlineElement - = Text !String + = Text !Text | Italic ![InlineElement] - | Bold ![InlineElement] + | Bold ![InlineElement] + | ObjectLink { + objLinkPage ∷ !PageName + , objLinkText ∷ !(Maybe Text) + } | PageLink { - linkPage :: !(Maybe PageName) - , linkFragment :: !(Maybe String) - , linkText :: !(Maybe String) + linkPage ∷ !(Maybe PageName) + , linkFragment ∷ !(Maybe Text) + , linkText ∷ !(Maybe Text) + } + | ExternalLink { + extLinkURI ∷ !URI + , extLinkText ∷ !(Maybe Text) } | LineBreak ![Attribute] - | Span ![Attribute] ![InlineElement] - | Image ![Attribute] - | Anchor ![Attribute] ![InlineElement] - | InlineCmd !InlineCommand - deriving (Eq, Show, Typeable, Data) - - -data ListElement - = ListElement { - listType :: !ListType - , listItems :: ![ListItem] + | Span ![Attribute] ![InlineElement] + | Image { + imgSource ∷ !(Either URI PageName) + , imgAlt ∷ !(Maybe Text) } - deriving (Eq, Show, Typeable, Data) - + | Anchor ![Attribute] ![InlineElement] + | Input ![Attribute] + | EmptyInline + | InlineCmd !InlineCommand + deriving (Eq, Show) data ListType = Bullet | Numbered - deriving (Eq, Show, Typeable, Data) - - -type ListItem = [Either ListElement InlineElement] + deriving (Eq, Show) +type ListItem = [Element] data Definition = Definition { - defTerm :: ![InlineElement] - , defDesc :: ![InlineElement] + defTerm ∷ ![InlineElement] + , defDesc ∷ ![InlineElement] } - deriving (Eq, Show, Typeable, Data) - + deriving (Eq, Show) data CommandType = InlineCommandType | BlockCommandType deriving (Eq, Show) - -type Attribute = (String, String) - - data BlockCommand = BlockCommand { - bCmdName :: !String - , bCmdAttributes :: ![Attribute] - , bCmdContents :: ![BlockElement] + bCmdName ∷ !Text + , bCmdAttributes ∷ ![Attribute] + , bCmdContents ∷ ![BlockElement] } - deriving (Eq, Show, Typeable, Data) - + deriving (Eq, Show) data InlineCommand = InlineCommand { - iCmdName :: !String + iCmdName :: !Text , iCmdAttributes :: ![Attribute] , iCmdContents :: ![InlineElement] } - deriving (Eq, Show, Typeable, Data) + deriving (Eq, Show)