Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides a set of data types to represent message text.
The types here are based loosely on the cheapskate
package's types
but provide higher-level support for the kinds of things we find in
Mattermost messages such as user and channel references.
To parse a Markdown document, use parseMarkdown
. To actually render
text in this representation, see the module RichText
.
Synopsis
- data RichTextBlock
- data ListType
- data CodeBlockInfo = CodeBlockInfo {}
- data NumDecoration
- data Element = Element {}
- data ElementData
- = EText Text
- | ESpace
- | ESoftBreak
- | ELineBreak
- | ERawHtml Text
- | EEditSentinel Bool
- | EUser Text
- | EChannel Text
- | EHyperlink URL (Maybe (Seq Element))
- | EImage URL (Maybe (Seq Element))
- | EEmoji Text
- | ENonBreaking (Seq Element)
- | EPermalink TeamURLName PostId (Maybe (Seq Element))
- data ElementStyle
- data TeamBaseURL = TeamBaseURL TeamURLName ServerBaseURL
- data TeamURLName = TeamURLName Text
- newtype URL = URL Text
- unURL :: URL -> Text
- parseMarkdown :: Maybe TeamBaseURL -> Text -> Seq RichTextBlock
- setElementStyle :: ElementStyle -> Element -> Element
- findUsernames :: Seq RichTextBlock -> Set Text
- blockGetURLs :: RichTextBlock -> [(Either (TeamURLName, PostId) URL, Maybe (Seq Element))]
- findVerbatimChunk :: Seq RichTextBlock -> Maybe Text
- fromMarkdownBlocks :: Maybe TeamBaseURL -> Blocks -> Seq RichTextBlock
Documentation
data RichTextBlock Source #
A block in a rich text document.
Para (Seq Element) | A paragraph. |
Header Int (Seq Element) | A section header with specified depth and contents. |
Blockquote (Seq RichTextBlock) | A blockquote. |
List Bool ListType (Seq (Seq RichTextBlock)) | An itemized list. |
CodeBlock CodeBlockInfo Text | A code block. |
HTMLBlock Text | A fragment of raw HTML. |
HRule | A horizontal rule. |
Instances
Show RichTextBlock Source # | |
Defined in Matterhorn.Types.RichText showsPrec :: Int -> RichTextBlock -> ShowS # show :: RichTextBlock -> String # showList :: [RichTextBlock] -> ShowS # |
The type of itemized list items.
Bullet Char | Decorate the items with bullet using the specified character. |
Numbered NumDecoration Int | Number the items starting at the specified number; use the indicated decoration following the number. |
data CodeBlockInfo Source #
Information about a code block.
CodeBlockInfo | |
|
Instances
Eq CodeBlockInfo Source # | |
Defined in Matterhorn.Types.RichText (==) :: CodeBlockInfo -> CodeBlockInfo -> Bool # (/=) :: CodeBlockInfo -> CodeBlockInfo -> Bool # | |
Ord CodeBlockInfo Source # | |
Defined in Matterhorn.Types.RichText compare :: CodeBlockInfo -> CodeBlockInfo -> Ordering # (<) :: CodeBlockInfo -> CodeBlockInfo -> Bool # (<=) :: CodeBlockInfo -> CodeBlockInfo -> Bool # (>) :: CodeBlockInfo -> CodeBlockInfo -> Bool # (>=) :: CodeBlockInfo -> CodeBlockInfo -> Bool # max :: CodeBlockInfo -> CodeBlockInfo -> CodeBlockInfo # min :: CodeBlockInfo -> CodeBlockInfo -> CodeBlockInfo # | |
Show CodeBlockInfo Source # | |
Defined in Matterhorn.Types.RichText showsPrec :: Int -> CodeBlockInfo -> ShowS # show :: CodeBlockInfo -> String # showList :: [CodeBlockInfo] -> ShowS # |
data NumDecoration Source #
Ways to decorate numbered itemized list items. The decoration follows the list item number.
Instances
Eq NumDecoration Source # | |
Defined in Matterhorn.Types.RichText (==) :: NumDecoration -> NumDecoration -> Bool # (/=) :: NumDecoration -> NumDecoration -> Bool # | |
Ord NumDecoration Source # | |
Defined in Matterhorn.Types.RichText compare :: NumDecoration -> NumDecoration -> Ordering # (<) :: NumDecoration -> NumDecoration -> Bool # (<=) :: NumDecoration -> NumDecoration -> Bool # (>) :: NumDecoration -> NumDecoration -> Bool # (>=) :: NumDecoration -> NumDecoration -> Bool # max :: NumDecoration -> NumDecoration -> NumDecoration # min :: NumDecoration -> NumDecoration -> NumDecoration # | |
Show NumDecoration Source # | |
Defined in Matterhorn.Types.RichText showsPrec :: Int -> NumDecoration -> ShowS # show :: NumDecoration -> String # showList :: [NumDecoration] -> ShowS # |
A single logical inline element in a rich text block.
Element | |
|
data ElementData Source #
The kinds of data that can appear in rich text elements.
EText Text | A sequence of non-whitespace characters. |
ESpace | A single space. |
ESoftBreak | A soft line break. |
ELineBreak | A hard line break. |
ERawHtml Text | Raw HTML. |
EEditSentinel Bool | A sentinel indicating that some text has been edited (used to indicate that mattermost messages have been edited by their authors). This has no parsable representation; it is only used to annotate a message prior to rendering to add a visual editing indicator. The boolean indicates whether the edit was "recent" (True) or not (False). |
EUser Text | A user reference. The text here includes only the username, not the sigil. |
EChannel Text | A channel reference. The text here includes only the channel name, not the sigil. |
EHyperlink URL (Maybe (Seq Element)) | A hyperlink to the specified URL. Optionally provides an element sequence indicating the URL's text label; if absent, the label is understood to be the URL itself. |
EImage URL (Maybe (Seq Element)) | An image at the specified URL. Optionally provides an element sequence indicating the image's "alt" text label; if absent, the label is understood to be the URL itself. |
EEmoji Text | An emoji reference. The text here includes only the text portion, not the colons, e.g. "foo" instead of ":foo:". |
ENonBreaking (Seq Element) | A sequence of elements that must never be separated during line wrapping. |
EPermalink TeamURLName PostId (Maybe (Seq Element)) | A permalink to the specified team (name) and post ID with an optional label. |
Instances
Eq ElementData Source # | |
Defined in Matterhorn.Types.RichText (==) :: ElementData -> ElementData -> Bool # (/=) :: ElementData -> ElementData -> Bool # | |
Ord ElementData Source # | |
Defined in Matterhorn.Types.RichText compare :: ElementData -> ElementData -> Ordering # (<) :: ElementData -> ElementData -> Bool # (<=) :: ElementData -> ElementData -> Bool # (>) :: ElementData -> ElementData -> Bool # (>=) :: ElementData -> ElementData -> Bool # max :: ElementData -> ElementData -> ElementData # min :: ElementData -> ElementData -> ElementData # | |
Show ElementData Source # | |
Defined in Matterhorn.Types.RichText showsPrec :: Int -> ElementData -> ShowS # show :: ElementData -> String # showList :: [ElementData] -> ShowS # |
data ElementStyle Source #
Element visual styles.
Normal | Normal text |
Emph | Emphasized text |
Strikethrough | Strikethrough text |
Strong | Bold text |
Code | Inline code segment or code block |
Hyperlink URL ElementStyle | A terminal hyperlink to the specified URL, composed with another element style |
Permalink | A post permalink |
Instances
Eq ElementStyle Source # | |
Defined in Matterhorn.Types.RichText (==) :: ElementStyle -> ElementStyle -> Bool # (/=) :: ElementStyle -> ElementStyle -> Bool # | |
Ord ElementStyle Source # | |
Defined in Matterhorn.Types.RichText compare :: ElementStyle -> ElementStyle -> Ordering # (<) :: ElementStyle -> ElementStyle -> Bool # (<=) :: ElementStyle -> ElementStyle -> Bool # (>) :: ElementStyle -> ElementStyle -> Bool # (>=) :: ElementStyle -> ElementStyle -> Bool # max :: ElementStyle -> ElementStyle -> ElementStyle # min :: ElementStyle -> ElementStyle -> ElementStyle # | |
Show ElementStyle Source # | |
Defined in Matterhorn.Types.RichText showsPrec :: Int -> ElementStyle -> ShowS # show :: ElementStyle -> String # showList :: [ElementStyle] -> ShowS # |
data TeamBaseURL Source #
A server base URL with a team name.
Instances
Eq TeamBaseURL Source # | |
Defined in Matterhorn.Types.RichText (==) :: TeamBaseURL -> TeamBaseURL -> Bool # (/=) :: TeamBaseURL -> TeamBaseURL -> Bool # | |
Show TeamBaseURL Source # | |
Defined in Matterhorn.Types.RichText showsPrec :: Int -> TeamBaseURL -> ShowS # show :: TeamBaseURL -> String # showList :: [TeamBaseURL] -> ShowS # |
data TeamURLName Source #
A team name found in a Mattermost post URL
Instances
Eq TeamURLName Source # | |
Defined in Matterhorn.Types.RichText (==) :: TeamURLName -> TeamURLName -> Bool # (/=) :: TeamURLName -> TeamURLName -> Bool # | |
Ord TeamURLName Source # | |
Defined in Matterhorn.Types.RichText compare :: TeamURLName -> TeamURLName -> Ordering # (<) :: TeamURLName -> TeamURLName -> Bool # (<=) :: TeamURLName -> TeamURLName -> Bool # (>) :: TeamURLName -> TeamURLName -> Bool # (>=) :: TeamURLName -> TeamURLName -> Bool # max :: TeamURLName -> TeamURLName -> TeamURLName # min :: TeamURLName -> TeamURLName -> TeamURLName # | |
Show TeamURLName Source # | |
Defined in Matterhorn.Types.RichText showsPrec :: Int -> TeamURLName -> ShowS # show :: TeamURLName -> String # showList :: [TeamURLName] -> ShowS # |
parseMarkdown :: Maybe TeamBaseURL -> Text -> Seq RichTextBlock Source #
setElementStyle :: ElementStyle -> Element -> Element Source #
findUsernames :: Seq RichTextBlock -> Set Text Source #
Obtain all username references in a sequence of rich text blocks.
blockGetURLs :: RichTextBlock -> [(Either (TeamURLName, PostId) URL, Maybe (Seq Element))] Source #
Obtain all URLs (and optional labels) in a rich text block.
findVerbatimChunk :: Seq RichTextBlock -> Maybe Text Source #
Find the first code block in a sequence of rich text blocks.
fromMarkdownBlocks :: Maybe TeamBaseURL -> Blocks -> Seq RichTextBlock Source #
Convert a sequence of markdown (Cheapskate) blocks into rich text blocks.