diff options
-rw-r--r-- | src/Text/Pandoc/Extensions.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/OPML.hs | 23 | ||||
-rw-r--r-- | test/command/4164.md | 35 |
3 files changed, 50 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs index 771898d70..bea293891 100644 --- a/src/Text/Pandoc/Extensions.hs +++ b/src/Text/Pandoc/Extensions.hs @@ -343,6 +343,7 @@ getDefaultExtensions "textile" = extensionsFromList Ext_smart, Ext_raw_html, Ext_auto_identifiers] +getDefaultExtensions "opml" = pandocExtensions -- affects notes getDefaultExtensions _ = extensionsFromList [Ext_auto_identifiers] 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) diff --git a/test/command/4164.md b/test/command/4164.md new file mode 100644 index 000000000..8cfc960a0 --- /dev/null +++ b/test/command/4164.md @@ -0,0 +1,35 @@ +``` +% pandoc -f opml -t markdown +<?xml version="1.0"?> <opml version="1.0"> <head> <title> test </title> </head> <body> <outline text="test"> <outline text="try" _note="Here is inline html:

<div> 
<balise>
bla bla
</div>"/> </outline> </body> </opml> +^D +test +==== + +try +--- + +Here is inline html: + +<div> + +<balise> bla bla + +</div> + +``` + +``` +% pandoc -f opml-raw_html-native_divs -t markdown +<?xml version="1.0"?> <opml version="1.0"> <head> <title> test </title> </head> <body> <outline text="test"> <outline text="try" _note="Here is inline html:

<div> 
<balise>
bla bla
</div>"/> </outline> </body> </opml> +^D +test +==== + +try +--- + +Here is inline html: + +\<div\> \<balise\> bla bla \</div\> + +``` |