brick-0.2.3: A declarative terminal user interface library

Safe HaskellNone
LanguageHaskell2010

Data.Text.Markup

Description

This module provides an API for "marking up" text with arbitrary values. A piece of markup can then be converted to a list of pairs representing the sequences of characters assigned the same markup value.

This interface is experimental. Don't use this for your full-file syntax highlighter just yet!

Synopsis

Documentation

data Markup a Source

Markup with metadata type a assigned to each character.

Instances

markupToList :: Eq a => Markup a -> [(Text, a)] Source

Convert markup to a list of pairs in which each pair contains the longest subsequence of characters having the same metadata.

markupSet :: Eq a => (Int, Int) -> a -> Markup a -> Markup a Source

Set the metadata for a range of character positions in a piece of markup. This is useful for, e.g., syntax highlighting.

fromList :: [(Text, a)] -> Markup a Source

Convert a list of text and metadata pairs into markup.

fromText :: Default a => Text -> Markup a Source

Build markup from text with the default metadata.

toText :: Eq a => Markup a -> Text Source

Extract the text from markup, discarding the markup metadata.

(@@) :: Text -> a -> Markup a Source

Build a piece of markup; assign the specified metadata to every character in the specified text.