pandoc-3.7.0.2: 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 #

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 # |
Instance details Defined in Text.Pandoc.Sources Methods mempty :: Sources # mappend :: Sources -> Sources -> Sources # mconcat :: [Sources] -> Sources #
Semigroup Sources # |
Instance details Defined in Text.Pandoc.Sources Methods (<>) :: Sources -> Sources -> Sources # sconcat :: NonEmpty Sources -> Sources # stimes :: Integral b => b -> Sources -> Sources #
IsString Sources # |
Instance details Defined in Text.Pandoc.Sources Methods fromString :: String -> Sources #
Show Sources # |
Instance details Defined in Text.Pandoc.Sources Methods showsPrec :: Int -> Sources -> ShowS # show :: Sources -> String # showList :: [Sources] -> ShowS #
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 Sources # |
Instance details Defined in Text.Pandoc.Sources Methods toSources :: Sources -> Sources #
ToSources Text # |
Instance details Defined in Text.Pandoc.Sources Methods toSources :: Text -> 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 ByteString Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> ByteString -> SourcePos #
UpdateSourcePos ByteString Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> ByteString -> SourcePos #
UpdateSourcePos Sources Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> Sources -> SourcePos #
UpdateSourcePos Text Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> Text -> SourcePos #
UpdateSourcePos [Char] Char # |
Instance details Defined in Text.Pandoc.Sources Methods updateSourcePos :: SourcePos -> Char -> [Char] -> SourcePos #

sourcesToText :: Sources -> Text #

initialSourceName :: Sources -> FilePath #

Get name of first source in `Sources`.

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

ensureFinalNewlines #

Arguments

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

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

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 #

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 #