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 Source #

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 Source # |
Instance details Defined in Text.Pandoc.Format Methods showsPrec :: Int -> FlavoredFormat -> ShowS Source # show :: FlavoredFormat -> String Source # showList :: [FlavoredFormat] -> ShowS Source #

data ExtensionsConfig Source #

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

data ExtensionsDiff Source #

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

diffExtensions :: Extensions -> Extensions -> ExtensionsDiff Source #

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

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

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 Source #

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 Source #

Returns the extensions configuration of a format.

formatFromFilePaths :: [FilePath] -> Maybe FlavoredFormat Source #

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"