aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index e12aa055c..b65e7130d 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -138,12 +138,34 @@ import Text.Pandoc.Options
import Data.ByteString.Lazy (ByteString)
import Data.Version (showVersion)
import Text.JSON.Generic
+import Data.Set (Set)
+import qualified Data.Set as Set
+import Text.Parsec
import Paths_pandoc (version)
-- | Version number of pandoc library.
pandocVersion :: String
pandocVersion = showVersion version
+parseFormatSpec :: String
+ -> Either ParseError (String, Set Extension -> Set Extension)
+parseFormatSpec = parse formatSpec ""
+ where formatSpec = do
+ name <- formatName
+ extMods <- many extMod
+ return (name, foldl (.) id extMods)
+ formatName = many1 $ noneOf "-+"
+ extMod = do
+ polarity <- oneOf "-+"
+ name <- many1 $ noneOf "-+"
+ ext <- case reads name of
+ ((n,[]):_) -> return n
+ _ -> unexpected $ "Unknown extension: " ++
+ name
+ return $ case polarity of
+ '-' -> Set.delete ext
+ _ -> Set.insert ext
+
-- | Association list of formats and readers.
readers :: [(String, ReaderOptions -> String -> Pandoc)]
readers = [("native" , \_ -> readNative)