Text.Pandoc.Format

pandoc-3.7.0.2: Conversion between markup formats

Copyright | © 2022-2024 Albert Krewinkel
License | GPL-2.0-or-later
Maintainer | Albert Krewinkel <albert+pandoc@tarleb.com>
Safe Haskell | None
Language | Haskell2010

Text.Pandoc.Format

Description

Handling of format specifiers for input and output.

Synopsis

- data FlavoredFormat = FlavoredFormat {
  - formatName :: Text
  - formatExtsDiff :: ExtensionsDiff
  }
- data ExtensionsConfig = ExtensionsConfig {
  - extsDefault :: Extensions
  - extsSupported :: Extensions
  }
- data ExtensionsDiff = ExtensionsDiff {
  - extsToEnable :: Extensions
  - extsToDisable :: Extensions
  }
- diffExtensions :: Extensions -> Extensions -> ExtensionsDiff
- parseFlavoredFormat :: PandocMonad m => Text -> m FlavoredFormat
- applyExtensionsDiff :: PandocMonad m => ExtensionsConfig -> FlavoredFormat -> m Extensions
- getExtensionsConfig :: Text -> ExtensionsConfig
- formatFromFilePaths :: [FilePath] -> Maybe FlavoredFormat

# Documentation

data FlavoredFormat #

Format specifier with the format's name and the lists of extensions to be enabled or disabled.

Constructors

FlavoredFormat |
Fields formatName :: Text formatExtsDiff :: ExtensionsDiff

#### Instances

Instances details

Show FlavoredFormat # |
Instance details Defined in Text.Pandoc.Format Methods showsPrec :: Int -> FlavoredFormat -> ShowS # show :: FlavoredFormat -> String # showList :: [FlavoredFormat] -> ShowS #

data ExtensionsConfig #

Describes the properties of a format.

Constructors

ExtensionsConfig |
Fields extsDefault :: Extensions Extensions enabled by default extsSupported :: Extensions Extensions that can be enabled or disabled.

#### Instances

Instances details

Monoid ExtensionsConfig # |
Instance details Defined in Text.Pandoc.Format Methods mempty :: ExtensionsConfig # mappend :: ExtensionsConfig -> ExtensionsConfig -> ExtensionsConfig # mconcat :: [ExtensionsConfig] -> ExtensionsConfig #
Semigroup ExtensionsConfig # |
Instance details Defined in Text.Pandoc.Format Methods (<>) :: ExtensionsConfig -> ExtensionsConfig -> ExtensionsConfig # sconcat :: NonEmpty ExtensionsConfig -> ExtensionsConfig # stimes :: Integral b => b -> ExtensionsConfig -> ExtensionsConfig #
Show ExtensionsConfig # |
Instance details Defined in Text.Pandoc.Format Methods showsPrec :: Int -> ExtensionsConfig -> ShowS # show :: ExtensionsConfig -> String # showList :: [ExtensionsConfig] -> ShowS #

data ExtensionsDiff #

Changes to a set of extensions, i.e., list of extensions to be enabled or disabled.

Constructors

ExtensionsDiff |
Fields extsToEnable :: Extensions extsToDisable :: Extensions

#### Instances

Instances details

Monoid ExtensionsDiff # |
Instance details Defined in Text.Pandoc.Format Methods mempty :: ExtensionsDiff # mappend :: ExtensionsDiff -> ExtensionsDiff -> ExtensionsDiff # mconcat :: [ExtensionsDiff] -> ExtensionsDiff #
Semigroup ExtensionsDiff # |
Instance details Defined in Text.Pandoc.Format Methods (<>) :: ExtensionsDiff -> ExtensionsDiff -> ExtensionsDiff # sconcat :: NonEmpty ExtensionsDiff -> ExtensionsDiff # stimes :: Integral b => b -> ExtensionsDiff -> ExtensionsDiff #
Show ExtensionsDiff # |
Instance details Defined in Text.Pandoc.Format Methods showsPrec :: Int -> ExtensionsDiff -> ShowS # show :: ExtensionsDiff -> String # showList :: [ExtensionsDiff] -> ShowS #

diffExtensions :: Extensions -> Extensions -> ExtensionsDiff #

Calculate the change set to get from one set of extensions to another.

parseFlavoredFormat :: PandocMonad m => Text -> m FlavoredFormat #

Parse a format-specifying string into a markup format and the change set to the format's extensions. Throws an error if the spec cannot be parsed or contains an unknown extension.

applyExtensionsDiff :: PandocMonad m => ExtensionsConfig -> FlavoredFormat -> m Extensions #

Apply the extension changes in the format spec to the extensions given in the format's extensions configuration. Throws an error in case of an unknown or unsupported extension.

getExtensionsConfig :: Text -> ExtensionsConfig #

Returns the extensions configuration of a format.

formatFromFilePaths :: [FilePath] -> Maybe FlavoredFormat #

Determines default format based on file extensions; uses the format of the first extension that's associated with a format.

Examples:

    formatFromFilePaths ["text.unknown", "no-extension"]

Nothing

    formatFromFilePaths ["my.md", "other.rst"]

Just "markdown"