trifecta-2.1.4: A modern parser combinator library with convenient diagnostics

Copyright | (C) 2011-2019 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | None
Language | Haskell2010

Text.Trifecta.Highlight

Description

Synopsis

- data Highlight
- data HighlightedRope = HighlightedRope !(IntervalMap Delta Highlight) !Rope
- class HasHighlightedRope c where
  - highlightedRope :: Lens' c HighlightedRope
  - ropeContent :: Lens' c Rope
  - ropeHighlights :: Lens' c (IntervalMap Delta Highlight)
- withHighlight :: Highlight -> Doc AnsiStyle -> Doc AnsiStyle
- data HighlightDoc = HighlightDoc String String HighlightedRope
- class HasHighlightDoc c where
  - highlightDoc :: Lens' c HighlightDoc
  - docContent :: Lens' c HighlightedRope
  - docCss :: Lens' c String
  - docTitle :: Lens' c String
- doc :: String -> HighlightedRope -> HighlightDoc

# Documentation

data Highlight Source #

Tags used by the `TokenParsing` `highlight` combinator.

#### Instances

Instances details

Bounded Highlight |
Instance details Defined in Text.Parser.Token.Highlight Methods minBound :: Highlight Source # maxBound :: Highlight Source #
Enum Highlight |

Instance details

Defined in Text.Parser.Token.Highlight

Methods

succ :: Highlight -> Highlight Source #

pred :: Highlight -> Highlight Source #

toEnum :: Int -> Highlight Source #

fromEnum :: Highlight -> Int Source #

enumFrom :: Highlight -> [Highlight] Source #

enumFromThen :: Highlight -> Highlight -> [Highlight] Source #

enumFromTo :: Highlight -> Highlight -> [Highlight] Source #

enumFromThenTo :: Highlight -> Highlight -> Highlight -> [Highlight] Source #

Read Highlight |
Instance details Defined in Text.Parser.Token.Highlight Methods readsPrec :: Int -> ReadS Highlight Source # readList :: ReadS [Highlight] Source # readPrec :: ReadPrec Highlight Source # readListPrec :: ReadPrec [Highlight] Source #
Show Highlight |
Instance details Defined in Text.Parser.Token.Highlight Methods showsPrec :: Int -> Highlight -> ShowS Source # show :: Highlight -> String Source # showList :: [Highlight] -> ShowS Source #
Eq Highlight |
Instance details Defined in Text.Parser.Token.Highlight Methods (==) :: Highlight -> Highlight -> Bool Source # (/=) :: Highlight -> Highlight -> Bool Source #
Ord Highlight |

Instance details

Defined in Text.Parser.Token.Highlight

Methods

compare :: Highlight -> Highlight -> Ordering Source #

(<) :: Highlight -> Highlight -> Bool Source #

(<=) :: Highlight -> Highlight -> Bool Source #

(>) :: Highlight -> Highlight -> Bool Source #

(>=) :: Highlight -> Highlight -> Bool Source #

max :: Highlight -> Highlight -> Highlight Source #

min :: Highlight -> Highlight -> Highlight Source #

data HighlightedRope Source #

A `HighlightedRope` is a `Rope` with an associated `IntervalMap` full of highlighted regions.

Constructors

HighlightedRope !(IntervalMap Delta Highlight) !Rope |

#### Instances

Instances details

ToMarkup HighlightedRope Source # |
Instance details Defined in Text.Trifecta.Highlight Methods toMarkup :: HighlightedRope -> Markup Source # preEscapedToMarkup :: HighlightedRope -> Markup Source #
Monoid HighlightedRope Source # |
Instance details Defined in Text.Trifecta.Highlight Methods mempty :: HighlightedRope Source # mappend :: HighlightedRope -> HighlightedRope -> HighlightedRope Source # mconcat :: [HighlightedRope] -> HighlightedRope Source #
Semigroup HighlightedRope Source # |
Instance details Defined in Text.Trifecta.Highlight Methods (<>) :: HighlightedRope -> HighlightedRope -> HighlightedRope Source # sconcat :: NonEmpty HighlightedRope -> HighlightedRope Source # stimes :: Integral b => b -> HighlightedRope -> HighlightedRope Source #
HasBytes HighlightedRope Source # |
Instance details Defined in Text.Trifecta.Highlight Methods bytes :: HighlightedRope -> Int64 Source #
HasDelta HighlightedRope Source # |
Instance details Defined in Text.Trifecta.Highlight Methods delta :: HighlightedRope -> Delta Source #
HasHighlightedRope HighlightedRope Source # |
Instance details Defined in Text.Trifecta.Highlight Methods highlightedRope :: Lens' HighlightedRope HighlightedRope Source # ropeContent :: Lens' HighlightedRope Rope Source # ropeHighlights :: Lens' HighlightedRope (IntervalMap Delta Highlight) Source #

class HasHighlightedRope c where Source #

Minimal complete definition

highlightedRope

Methods

highlightedRope :: Lens' c HighlightedRope Source #

ropeContent :: Lens' c Rope Source #

ropeHighlights :: Lens' c (IntervalMap Delta Highlight) Source #

#### Instances

Instances details

HasHighlightedRope HighlightedRope Source # |
Instance details Defined in Text.Trifecta.Highlight Methods highlightedRope :: Lens' HighlightedRope HighlightedRope Source # ropeContent :: Lens' HighlightedRope Rope Source # ropeHighlights :: Lens' HighlightedRope (IntervalMap Delta Highlight) Source #

withHighlight :: Highlight -> Doc AnsiStyle -> Doc AnsiStyle Source #

Convert a `Highlight` into a coloration on a `Doc`.

data HighlightDoc Source #

Represents a source file like an HsColour rendered document

Constructors

HighlightDoc String String HighlightedRope |

#### Instances

Instances details

ToMarkup HighlightDoc Source # |
Instance details Defined in Text.Trifecta.Highlight Methods toMarkup :: HighlightDoc -> Markup Source # preEscapedToMarkup :: HighlightDoc -> Markup Source #
HasHighlightDoc HighlightDoc Source # |
Instance details Defined in Text.Trifecta.Highlight Methods highlightDoc :: Lens' HighlightDoc HighlightDoc Source # docContent :: Lens' HighlightDoc HighlightedRope Source # docCss :: Lens' HighlightDoc String Source # docTitle :: Lens' HighlightDoc String Source #

class HasHighlightDoc c where Source #

Minimal complete definition

highlightDoc

Methods

highlightDoc :: Lens' c HighlightDoc Source #

docContent :: Lens' c HighlightedRope Source #

docCss :: Lens' c String Source #

docTitle :: Lens' c String Source #

#### Instances

Instances details

HasHighlightDoc HighlightDoc Source # |
Instance details Defined in Text.Trifecta.Highlight Methods highlightDoc :: Lens' HighlightDoc HighlightDoc Source # docContent :: Lens' HighlightDoc HighlightedRope Source # docCss :: Lens' HighlightDoc String Source # docTitle :: Lens' HighlightDoc String Source #

doc :: String -> HighlightedRope -> HighlightDoc Source #

Generate an HTML document from a title and a `HighlightedRope`.