matterhorn-50200.11.0: Terminal client for the Mattermost chat system

Safe HaskellNone
LanguageHaskell2010

Matterhorn.Types.RichText

Description

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

Documentation

data RichTextBlock Source #

A block in a rich text document.

Constructors

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.

data ListType Source #

The type of itemized list items.

Constructors

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.

Constructors

CodeBlockInfo 

Fields

  • codeBlockLanguage :: Maybe Text

    The language of the source code in the code block, if any. This is encoded in Markdown as a sequence of non-whitespace characters following the fenced code block opening backticks.

  • codeBlockInfo :: Maybe Text

    Any text that comes after the language token. This text is separated from the language token by whitespace.

data NumDecoration Source #

Ways to decorate numbered itemized list items. The decoration follows the list item number.

Constructors

Paren 
Period 

data Element Source #

A single logical inline element in a rich text block.

Constructors

Element 

Fields

Instances
Eq Element Source # 
Instance details

Defined in Matterhorn.Types.RichText

Methods

(==) :: Element -> Element -> Bool #

(/=) :: Element -> Element -> Bool #

Ord Element Source # 
Instance details

Defined in Matterhorn.Types.RichText

Show Element Source # 
Instance details

Defined in Matterhorn.Types.RichText

data ElementData Source #

The kinds of data that can appear in rich text elements.

Constructors

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.

data ElementStyle Source #

Element visual styles.

Constructors

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

data TeamBaseURL Source #

A server base URL with a team name.

newtype URL Source #

A URL.

Constructors

URL Text 
Instances
Eq URL Source # 
Instance details

Defined in Matterhorn.Types.RichText

Methods

(==) :: URL -> URL -> Bool #

(/=) :: URL -> URL -> Bool #

Ord URL Source # 
Instance details

Defined in Matterhorn.Types.RichText

Methods

compare :: URL -> URL -> Ordering #

(<) :: URL -> URL -> Bool #

(<=) :: URL -> URL -> Bool #

(>) :: URL -> URL -> Bool #

(>=) :: URL -> URL -> Bool #

max :: URL -> URL -> URL #

min :: URL -> URL -> URL #

Show URL Source # 
Instance details

Defined in Matterhorn.Types.RichText

Methods

showsPrec :: Int -> URL -> ShowS #

show :: URL -> String #

showList :: [URL] -> ShowS #

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.