brick-0.18: A declarative terminal user interface library

Safe Haskell | Safe
Language | Haskell2010

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

- data Markup a
- markupToList :: Eq a => Markup a -> [[(Text, a)]]
- markupSet :: Eq a => (Int, Int) -> a -> Markup a -> Markup a
- fromList :: [(Text, a)] -> Markup a
- fromText :: Monoid a => Text -> Markup a
- toText :: Eq a => Markup a -> Text
- (@@) :: Text -> a -> Markup a

# Documentation

data Markup a Source #

Markup with metadata type `a` assigned to each character.

Instances

Show a => Show (Markup a) Source # |
Methods showsPrec :: Int -> Markup a -> ShowS # show :: Markup a -> String # showList :: [Markup a] -> ShowS #
Monoid a => IsString (Markup a) Source # |
Methods fromString :: String -> Markup a #
Monoid (Markup a) Source # |
Methods mempty :: Markup a # mappend :: Markup a -> Markup a -> Markup a # mconcat :: [Markup a] -> Markup a #

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

Convert markup to a list of lines. Each line is represented by 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 :: Monoid 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.