@@ -138,12 +138,34 @@ import Text.Pandoc.Options
138import Data.ByteString.Lazy (ByteString)
138import Data.ByteString.Lazy (ByteString)
139import Data.Version (showVersion)
139import Data.Version (showVersion)
140import Text.JSON.Generic
140import Text.JSON.Generic
141+import Data.Set (Set)
142+import qualified Data.Set as Set
141import Paths_pandoc (version)
144import Paths_pandoc (version)
143-- | Version number of pandoc library.
146-- | Version number of pandoc library.
144pandocVersion :: String
147pandocVersion :: String
145pandocVersion = showVersion version
148pandocVersion = showVersion version
150+parseFormatSpec :: String
151+ -> Either ParseError (String, Set Extension -> Set Extension)
152+parseFormatSpec = parse formatSpec ""
153+ where formatSpec = do
155+ extMods <- many extMod
156+ return (name, foldl (.) id extMods)
157+ formatName = many1 $ noneOf "-+"
159+ polarity <- oneOf "-+"
160+ name <- many1 $ noneOf "-+"
161+ ext <- case reads name of
162+ ((n,[]):_) -> return n
163+ _ -> unexpected $ "Unknown extension: " ++
165+ return $ case polarity of
166+ '-' -> Set.delete ext
147-- | Association list of formats and readers.
169-- | Association list of formats and readers.
148readers :: [(String, ReaderOptions -> String -> Pandoc)]
170readers :: [(String, ReaderOptions -> String -> Pandoc)]
149readers = [("native" , \_ -> readNative)
171readers = [("native" , \_ -> readNative)