diff options
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/EPUB.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 14 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 19 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 4 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Inlines.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 6 |
6 files changed, 23 insertions, 26 deletions
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs index f24adb5b1..851d4771f 100644 --- a/src/Text/Pandoc/Readers/EPUB.hs +++ b/src/Text/Pandoc/Readers/EPUB.hs @@ -13,6 +13,7 @@ import Text.Pandoc.Definition hiding (Attr) import Text.Pandoc.Readers.HTML (readHtml) import Text.Pandoc.Walk (walk, query) import Text.Pandoc.Options ( ReaderOptions(..), Verbosity(..)) +import Text.Pandoc.Extensions (enableExtension, Extension(Ext_raw_html)) import Text.Pandoc.Shared (escapeURI, collapseFilePath, addMetaField) import Network.URI (unEscapeString) import Text.Pandoc.MediaBag (MediaBag, insertMedia) @@ -66,7 +67,7 @@ archiveToEPUB os archive = do P.setMediaBag $ fetchImages (M.elems items) root archive ast return ast where - os' = os {readerParseRaw = True} + os' = os {readerExtensions = enableExtension Ext_raw_html (readerExtensions os)} parseSpineElem :: PandocMonad m => FilePath -> (FilePath, MimeType) -> m Pandoc parseSpineElem (normalise -> r) (normalise -> path, mime) = do report DEBUG ("parseSpineElem called with path " ++ show path) diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 0bb837ba9..219ee81b6 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -45,9 +45,9 @@ import qualified Text.Pandoc.Builder as B import Text.Pandoc.Builder (Blocks, Inlines, trimInlines, HasMeta(..)) import Text.Pandoc.Shared ( extractSpaces, renderTags', addMetaField , escapeURI, safeRead ) -import Text.Pandoc.Options (ReaderOptions(readerParseRaw), - Verbosity(..), Extension (Ext_epub_html_exts, - Ext_native_divs, Ext_native_spans)) +import Text.Pandoc.Options (ReaderOptions(readerExtensions), extensionEnabled, + Verbosity(..), Extension (Ext_epub_html_exts, + Ext_raw_html, Ext_native_divs, Ext_native_spans)) import Text.Pandoc.Parsing hiding ((<|>)) import Text.Pandoc.Walk import qualified Data.Map as M @@ -367,8 +367,8 @@ pDiv = try $ do pRawHtmlBlock :: PandocMonad m => TagParser m Blocks pRawHtmlBlock = do raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag - parseRaw <- getOption readerParseRaw - if parseRaw && not (null raw) + exts <- getOption readerExtensions + if extensionEnabled Ext_raw_html exts && not (null raw) then return $ B.rawBlock "html" raw else return mempty @@ -690,8 +690,8 @@ pRawHtmlInline = do <|> if inplain then pSatisfy (not . isBlockTag) else pSatisfy isInlineTag - parseRaw <- getOption readerParseRaw - if parseRaw + exts <- getOption readerExtensions + if extensionEnabled Ext_raw_html exts then return $ B.rawInline "html" $ renderTags' [result] else return mempty diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 86ff2b83a..ea284efef 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -303,14 +303,18 @@ ignoreInlines name = (name, doraw <|> (mempty <$ optargs)) where optargs = skipopts *> skipMany (try $ optional sp *> braced) contseq = '\\':name doraw = (rawInline "latex" . (contseq ++) . snd) <$> - (getOption readerParseRaw >>= guard >> withRaw optargs) + (do exts <- getOption readerExtensions + guard $ extensionEnabled Ext_raw_tex exts + withRaw optargs) ignoreBlocks :: PandocMonad m => String -> (String, LP m Blocks) ignoreBlocks name = (name, doraw <|> (mempty <$ optargs)) where optargs = skipopts *> skipMany (try $ optional sp *> braced) contseq = '\\':name doraw = (rawBlock "latex" . (contseq ++) . snd) <$> - (getOption readerParseRaw >>= guard >> withRaw optargs) + (do exts <- getOption readerExtensions + guard $ extensionEnabled Ext_raw_tex exts + withRaw optargs) blockCommands :: PandocMonad m => M.Map String (LP m Blocks) blockCommands = M.fromList $ @@ -423,7 +427,7 @@ inlineCommand = try $ do name <- anyControlSeq guard $ name /= "begin" && name /= "end" guard $ not $ isBlockCommand name - parseRaw <- getOption readerParseRaw + exts <- getOption readerExtensions star <- option "" (string "*") let name' = name ++ star let raw = do @@ -433,7 +437,7 @@ inlineCommand = try $ do transformed <- applyMacros' rawcommand if transformed /= rawcommand then parseFromString inlines transformed - else if parseRaw + else if extensionEnabled Ext_raw_tex exts then return $ rawInline "latex" rawcommand else return mempty (lookupListDefault mzero [name',name] inlineCommands <* @@ -441,7 +445,8 @@ inlineCommand = try $ do <|> raw unlessParseRaw :: PandocMonad m => LP m () -unlessParseRaw = getOption readerParseRaw >>= guard . not +unlessParseRaw = getOption readerExtensions >>= + guard . not . extensionEnabled Ext_raw_tex isBlockCommand :: String -> Bool isBlockCommand s = s `M.member` (blockCommands :: M.Map String (LP PandocPure Blocks)) @@ -923,10 +928,10 @@ inlineEnvironment = try $ do rawEnv :: PandocMonad m => String -> LP m Blocks rawEnv name = do - parseRaw <- getOption readerParseRaw + exts <- getOption readerExtensions rawOptions <- mconcat <$> many rawopt let addBegin x = "\\begin{" ++ name ++ "}" ++ rawOptions ++ x - if parseRaw + if extensionEnabled Ext_raw_tex exts then (rawBlock "latex" . addBegin) <$> (withRaw (env name blocks) >>= applyMacros' . snd) else env name blocks diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 1d8f7c78e..0c10889d4 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -359,10 +359,6 @@ kvPair allowEmpty = try $ do parseMarkdown :: PandocMonad m => MarkdownParser m Pandoc parseMarkdown = do - -- markdown allows raw HTML - updateState $ \state -> state { stateOptions = - let oldOpts = stateOptions state in - oldOpts{ readerParseRaw = True } } optional titleBlock blocks <- parseBlocks st <- getState diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs index bcf8f6df9..f3671641a 100644 --- a/src/Text/Pandoc/Readers/Org/Inlines.hs +++ b/src/Text/Pandoc/Readers/Org/Inlines.hs @@ -806,7 +806,8 @@ inlineLaTeX = try $ do where clean = dropWhileEnd (`elem` ("{}" :: String)) . drop 1 state :: ParserState - state = def{ stateOptions = def{ readerParseRaw = True }} + state = def{ stateOptions = def{ readerExtensions = + enableExtension Ext_raw_tex (readerExtensions def) } } texMathToPandoc :: String -> Maybe [Inline] texMathToPandoc cs = (maybeRight $ readTeX cs) >>= writePandoc DisplayInline diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index 804ee39aa..07fb65b20 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -85,12 +85,6 @@ readTextile opts s = do -- | Generate a Pandoc ADT from a textile document parseTextile :: PandocMonad m => ParserT [Char] ParserState m Pandoc parseTextile = do - -- textile allows raw HTML and does smart punctuation by default, - -- but we do not enable smart punctuation unless it is explicitly - -- asked for, for better conversion to other light markup formats - oldOpts <- stateOptions `fmap` getState - updateState $ \state -> state{ stateOptions = - oldOpts{ readerParseRaw = True } } many blankline startPos <- getPosition -- go through once just to get list of reference keys and notes |