pandoc-3.2: Conversion between markup formats
Copyright© 2022-2024 Albert Krewinkel
LicenseGPL-2.0-or-later
MaintainerAlbert Krewinkel <pandoc@tarleb.com>
Safe HaskellNone
LanguageHaskell2010

Text.Pandoc.Format

Description

Handling of format specifiers for input and output.

Synopsis

Documentation

data FlavoredFormat Source #

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

Constructors

FlavoredFormat 

Instances

Instances details
Show FlavoredFormat Source # 
Instance details

Defined in Text.Pandoc.Format

Methods

showsPrec :: Int -> FlavoredFormat -> ShowS

show :: FlavoredFormat -> String

showList :: [FlavoredFormat] -> ShowS

data ExtensionsConfig Source #

Describes the properties of a format.

Constructors

ExtensionsConfig 

Fields

Instances

Instances details
Monoid ExtensionsConfig Source # 
Instance details

Defined in Text.Pandoc.Format

Semigroup ExtensionsConfig Source # 
Instance details

Defined in Text.Pandoc.Format

Show ExtensionsConfig Source # 
Instance details

Defined in Text.Pandoc.Format

Methods

showsPrec :: Int -> ExtensionsConfig -> ShowS

show :: ExtensionsConfig -> String

showList :: [ExtensionsConfig] -> ShowS

data ExtensionsDiff Source #

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

Instances

Instances details
Monoid ExtensionsDiff Source # 
Instance details

Defined in Text.Pandoc.Format

Semigroup ExtensionsDiff Source # 
Instance details

Defined in Text.Pandoc.Format

Show ExtensionsDiff Source # 
Instance details

Defined in Text.Pandoc.Format

Methods

showsPrec :: Int -> ExtensionsDiff -> ShowS

show :: ExtensionsDiff -> String

showList :: [ExtensionsDiff] -> ShowS

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"