brick-0.36.1: A declarative terminal user interface library

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

 Show a => Show (Markup a) Source # MethodsshowsPrec :: Int -> Markup a -> ShowS #show :: Markup a -> String #showList :: [Markup a] -> ShowS # Monoid a => IsString (Markup a) Source # Methods Source # Methods(<>) :: Markup a -> Markup a -> Markup a #sconcat :: NonEmpty (Markup a) -> Markup a #stimes :: Integral b => b -> Markup a -> Markup a # Monoid (Markup a) Source # Methodsmappend :: 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 #