pandoc-3.10: Conversion between markup formats

Copyright | Copyright (C) 2021-2024 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 :: forall (m :: Type -> Type) u. Monad m => SourcePos -> Text -> ParsecT Sources u m ()
- ensureFinalNewlines :: Int -> Sources -> Sources
- addToInput :: forall (m :: Type -> Type) u. Monad m => Text -> ParsecT Sources u m ()
- satisfy :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => (Char -> Bool) -> ParsecT s u m Char
- oneOf :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m Char
- noneOf :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m Char
- anyChar :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- char :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => Char -> ParsecT s u m Char
- string :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => [Char] -> ParsecT s u m [Char]
- newline :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- space :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- spaces :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m ()
- letter :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- digit :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- hexDigit :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char
- alphaNum :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char

# Documentation

newtype Sources Source #

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

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

class ToSources a where Source #

Methods

toSources :: a -> Sources Source #

#### Instances

Instances details

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

class UpdateSourcePos s c where Source #

Methods

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

#### Instances

Instances details

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

sourcesToText :: Sources -> Text Source #

initialSourceName :: Sources -> FilePath Source #

Get name of first source in `Sources`.

addToSources :: forall (m :: Type -> Type) u. Monad m => SourcePos -> Text -> ParsecT Sources u m () Source #

ensureFinalNewlines Source #

Arguments

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

addToInput :: forall (m :: Type -> Type) u. Monad m => Text -> ParsecT Sources u m () Source #

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

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

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

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

anyChar :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char Source #

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

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

newline :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char Source #

space :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char Source #

spaces :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m () Source #

letter :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char Source #

digit :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char Source #

hexDigit :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char Source #

alphaNum :: forall (m :: Type -> Type) s u. (Monad m, Stream s m Char, UpdateSourcePos s Char) => ParsecT s u m Char Source #