-- | -- 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 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.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 { Conversion -> String targetExtension :: !String -- ^ The extension of the target files , Conversion -> Text -> Text escaper :: Text -> Text -- ^ The function that escapes content text , Conversion -> Text -> Text preEscaper :: Text -> Text -- ^ The function that escapes preformatted text , Conversion -> Text -> Text attrEscaper :: Text -> Text -- ^ The function that escapes attributes , Conversion -> Template documentTemplate :: Template -- ^ The template for the final document , Conversion -> Template textTemplate :: Template -- ^ Paragraph element template , Conversion -> Template linkTemplate :: Template -- ^ Link element template , Conversion -> Template h1Template :: Template -- ^ Main heading element template , Conversion -> Template h2Template :: Template -- ^ Second level heading element template , Conversion -> Template h3Template :: Template -- ^ Third level heading element template , Conversion -> (Template, Template) listTemplates :: (Template, Template) -- ^ List element templates, the first being the list itself , Conversion -> Template quoteTemplate :: Template -- ^ Quote element template , Conversion -> Template preTemplate :: Template -- ^ Preformatted element template , Conversion -> [RewriteRule] rewriteRules :: ![RewriteRule] -- ^ List of RegEx rewrite rules , Conversion -> Values conversionOverrides :: !Values -- ^ Variable overrides for template formatting }