gemoire-1.0.0: src/Gemoire/Converter/Types.hs
-- |
-- Module : Gemoire.Converter.Types
-- Copyright : (c) 2025 Sena
-- License : GPL-3.0-or-later
--
-- Maintainer : contact@sena.pink
-- Stability : stable
-- Portability : portable
--
-- Types for the conversion
module Gemoire.Converter.Types
( RewriteRule
, Conversion (..)
) where
import Data.Text (Text)
import Text.Regex ()
import Gemoire.Template (Template, Values)
-- | A RegEx rewriting rule
--
-- The regular expressions must be POSIX extended variants, without the surrounding
-- forward slashes. You can use @\\1@ to get the substrings of matches for the
-- replacement string. See `Text.Regex' for more.
--
-- * The first field is a RegEx matching the input filename in which the rewriting will occur.
-- * The second field is the RegEx matching the string that will be replaced.
-- * The third field is the replacement string.
-- * The fourth field is whether the matching is multiline.
-- * The fifth field is whether the matching is case sensitive.
type RewriteRule = (String, String, String, Bool, Bool)
-- | A gemtext conversion recipe
--
-- See the module description for the variables available in each template.
data Conversion = Conversion
{ targetExtension :: !String
-- ^ The extension of the target files
, escaper :: Text -> Text
-- ^ The function that escapes content text
, preEscaper :: Text -> Text
-- ^ The function that escapes preformatted text
, attrEscaper :: Text -> Text
-- ^ The function that escapes attributes
, documentTemplate :: Template
-- ^ The template for the final document
, textTemplate :: Template
-- ^ Paragraph element template
, linkTemplate :: Template
-- ^ Link element template
, h1Template :: Template
-- ^ Main heading element template
, h2Template :: Template
-- ^ Second level heading element template
, h3Template :: Template
-- ^ Third level heading element template
, listTemplates :: (Template, Template)
-- ^ List element templates, the first being the list itself
, quoteTemplate :: Template
-- ^ Quote element template
, preTemplate :: Template
-- ^ Preformatted element template
, rewriteRules :: ![RewriteRule]
-- ^ List of RegEx rewrite rules
, conversionOverrides :: !Values
-- ^ Variable overrides for template formatting
}