aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-12-17 09:47:24 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-12-17 09:52:53 -0800
commit808f6d3fa1816401d9eb1d6a5d1821fb783cc1d5 (patch)
tree95cd11a3a778085779b113d1ee1fc9e5bd3700a4 /src/Text/Pandoc/Readers
parentd35e396f3ceb64df61fea02164ab56f1c3b140a2 (diff)
downloadpandoc-808f6d3fa1816401d9eb1d6a5d1821fb783cc1d5.tar.gz
OPML reader: enable raw HTML and other extensions by default for notes.
This fixes a regression in 2.0. Note that extensions can now be individually disabled, e.g. `-f opml-smart-raw_html`. Closes #4164.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/OPML.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/OPML.hs b/src/Text/Pandoc/Readers/OPML.hs
index 1a1375b16..68f3252a9 100644
--- a/src/Text/Pandoc/Readers/OPML.hs
+++ b/src/Text/Pandoc/Readers/OPML.hs
@@ -12,7 +12,7 @@ import Text.Pandoc.Class (PandocMonad)
import Text.Pandoc.Options
import Text.Pandoc.Readers.HTML (readHtml)
import Text.Pandoc.Readers.Markdown (readMarkdown)
-import Text.Pandoc.Shared (crFilter)
+import Text.Pandoc.Shared (crFilter, blocksToInlines)
import Text.XML.Light
type OPML m = StateT OPMLState m
@@ -22,6 +22,7 @@ data OPMLState = OPMLState{
, opmlDocTitle :: Inlines
, opmlDocAuthors :: [Inlines]
, opmlDocDate :: Inlines
+ , opmlOptions :: ReaderOptions
} deriving Show
instance Default OPMLState where
@@ -29,13 +30,14 @@ instance Default OPMLState where
, opmlDocTitle = mempty
, opmlDocAuthors = []
, opmlDocDate = mempty
- }
+ , opmlOptions = def
+ }
readOPML :: PandocMonad m => ReaderOptions -> Text -> m Pandoc
-readOPML _ inp = do
+readOPML opts inp = do
(bs, st') <- runStateT
(mapM parseBlock $ normalizeTree $
- parseXML (unpack (crFilter inp))) def
+ parseXML (unpack (crFilter inp))) def{ opmlOptions = opts }
return $
setTitle (opmlDocTitle st') $
setAuthors (opmlDocAuthors st') $
@@ -69,13 +71,16 @@ attrValue attr elt =
-- exceptT = either throwError return
asHtml :: PandocMonad m => String -> OPML m Inlines
-asHtml s =
- (\(Pandoc _ bs) -> case bs of
- [Plain ils] -> fromList ils
- _ -> mempty) <$> lift (readHtml def (pack s))
+asHtml s = do
+ opts <- gets opmlOptions
+ Pandoc _ bs <- readHtml def{ readerExtensions = readerExtensions opts } (pack s)
+ return $ fromList $ blocksToInlines bs
asMarkdown :: PandocMonad m => String -> OPML m Blocks
-asMarkdown s = (\(Pandoc _ bs) -> fromList bs) <$> lift (readMarkdown def (pack s))
+asMarkdown s = do
+ opts <- gets opmlOptions
+ Pandoc _ bs <- readMarkdown def{ readerExtensions = readerExtensions opts } (pack s)
+ return $ fromList bs
getBlocks :: PandocMonad m => Element -> OPML m Blocks
getBlocks e = mconcat <$> mapM parseBlock (elContent e)