pandoc-2.17.1.1: Conversion between markup formats

Copyright | Copyright (C) 2021-2022 John MacFarlane
License | GNU GPL, version 2 or above
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | portable
Safe Haskell | None
Language | Haskell2010

Text.Pandoc.Sources

Description

Defines Sources object to be used as input to pandoc parsers and redefines Char parsers so they get source position information from it.

Synopsis

- newtype Sources = Sources {
  - unSources :: [(SourcePos, Text)]
  }
- class ToSources a where
  - toSources :: a -> Sources
- class UpdateSourcePos s c where
  - updateSourcePos :: SourcePos -> c -> s -> SourcePos
- sourcesToText :: Sources -> Text
- initialSourceName :: Sources -> FilePath
- addToSources :: Monad m => SourcePos -> Text -> ParsecT Sources u m ()
- ensureFinalNewlines :: Int -> Sources -> Sources
- addToInput :: Monad m => Text -> ParsecT Sources u m ()
- satisfy :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => (Char -> Bool) -> ParsecT s u m Char
- oneOf :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m Char
- noneOf :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m Char
- anyChar :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- char :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => Char -> ParsecT s u m Char
- string :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m [Char]
- newline :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- space :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- spaces :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m ()
- letter :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- digit :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- hexDigit :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- alphaNum :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char

# Documentation

newtype Sources #

A list of inputs labeled with source positions. It is assumed that the `Text`s have `n` line endings.

Constructors

Sources |
Fields unSources :: [(SourcePos, Text)]

#### Instances

Instances details

Show Sources # |
Instance details Defined in Text.Pandoc.Sources Methods showsPrec :: Int -> Sources -> ShowS # show :: Sources -> String # showList :: [Sources] -> ShowS #
IsString Sources # |
Instance details Defined in Text.Pandoc.Sources Methods fromString :: String -> Sources #
Semigroup Sources # |
Instance details Defined in Text.Pandoc.Sources Methods (<>) :: Sources -> Sources -> Sources # sconcat :: NonEmpty Sources -> Sources # stimes :: Integral b => b -> Sources -> Sources #
Monoid Sources # |
Instance details Defined in Text.Pandoc.Sources Methods mempty :: Sources # mappend :: Sources -> Sources -> Sources # mconcat :: [Sources] -> Sources #
Pushable Sources # |
Instance details Defined in Text.Pandoc.Lua.Orphans Methods push :: LuaError e => Sources -> LuaE e () #
ToSources Sources # |
Instance details Defined in Text.Pandoc.Sources Methods toSources :: Sources -> Sources #
UpdateSourcePos Sources Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> Sources -> SourcePos #
Monad m => Stream Sources m Char # |
Instance details Defined in Text.Pandoc.Sources Methods uncons :: Sources -> m (Maybe (Char, Sources)) #

class ToSources a where #

Methods

toSources :: a -> Sources #

#### Instances

Instances details

ToSources Text # |
Instance details Defined in Text.Pandoc.Sources Methods toSources :: Text -> Sources #
ToSources Sources # |
Instance details Defined in Text.Pandoc.Sources Methods toSources :: Sources -> Sources #
ToSources [(FilePath, Text)] # |
Instance details Defined in Text.Pandoc.Sources Methods toSources :: [(FilePath, Text)] -> Sources #

class UpdateSourcePos s c where #

Methods

updateSourcePos :: SourcePos -> c -> s -> SourcePos #

#### Instances

Instances details

UpdateSourcePos Text Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> Text -> SourcePos #
UpdateSourcePos Sources Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> Sources -> SourcePos #

sourcesToText :: Sources -> Text #

initialSourceName :: Sources -> FilePath #

Get name of first source in `Sources`.

addToSources :: Monad m => SourcePos -> Text -> ParsecT Sources u m () #

ensureFinalNewlines #

Arguments

:: Int | number of trailing newlines
-> Sources |
-> Sources |

addToInput :: Monad m => Text -> ParsecT Sources u m () #

Add some text to the beginning of the input sources. This simplifies code that expands macros.

satisfy :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => (Char -> Bool) -> ParsecT s u m Char #

oneOf :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m Char #

noneOf :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m Char #

anyChar :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char #

char :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => Char -> ParsecT s u m Char #

string :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m [Char] #

newline :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char #

space :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char #

spaces :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m () #

letter :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char #

digit :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char #

hexDigit :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char #

alphaNum :: (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char #