aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Options.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Options.hs')
-rw-r--r--src/Text/Pandoc/Options.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 581f4c82a..03960b6b9 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -56,6 +56,9 @@ import Skylighting (SyntaxMap, defaultSyntaxMap)
import Text.Pandoc.Extensions
import Text.Pandoc.Highlighting (Style, pygments)
+class HasSyntaxExtensions a where
+ getExtensions :: a -> Extensions
+
data ReaderOptions = ReaderOptions{
readerExtensions :: Extensions -- ^ Syntax extensions
, readerStandalone :: Bool -- ^ Standalone document with header
@@ -69,6 +72,9 @@ data ReaderOptions = ReaderOptions{
, readerStripComments :: Bool -- ^ Strip HTML comments instead of parsing as raw HTML
} deriving (Show, Read, Data, Typeable, Generic)
+instance HasSyntaxExtensions ReaderOptions where
+ getExtensions opts = readerExtensions opts
+
instance ToJSON ReaderOptions where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ReaderOptions
@@ -259,6 +265,9 @@ instance Default WriterOptions where
, writerSyntaxMap = defaultSyntaxMap
}
+instance HasSyntaxExtensions WriterOptions where
+ getExtensions opts = writerExtensions opts
+
-- | Returns True if the given extension is enabled.
-isEnabled :: Extension -> WriterOptions -> Bool
-isEnabled ext opts = ext `extensionEnabled` writerExtensions opts
+isEnabled :: HasSyntaxExtensions a => Extension -> a -> Bool
+isEnabled ext opts = ext `extensionEnabled` getExtensions opts