git.iko.soy/typeable/pandoc
on master help sign in
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.

commit808f6d3fa1816401d9eb1d6a5d1821fb783cc1d5 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 17 Dec 2017, 09:47 (9 years ago) parentd35e396
3 files changed+50−9
src/Text/Pandoc/Extensions.hs+1 src/Text/Pandoc/Readers/OPML.hs+14−9 test/command/4164.md+35
src/Text/Pandoc/Extensions.hs+1
@@ -343,6 +343,7 @@ getDefaultExtensions "textile" = extensionsFromList
343343 Ext_smart,
344344 Ext_raw_html,
345345 Ext_auto_identifiers]
346+getDefaultExtensions "opml" = pandocExtensions -- affects notes
346347getDefaultExtensions _ = extensionsFromList
347348 [Ext_auto_identifiers]
348349
src/Text/Pandoc/Readers/OPML.hs+14−9
@@ -12,7 +12,7 @@ import Text.Pandoc.Class (PandocMonad)
1212import Text.Pandoc.Options
1313import Text.Pandoc.Readers.HTML (readHtml)
1414import Text.Pandoc.Readers.Markdown (readMarkdown)
15−import Text.Pandoc.Shared (crFilter)
15+import Text.Pandoc.Shared (crFilter, blocksToInlines)
1616import Text.XML.Light
1717
1818type OPML m = StateT OPMLState m
@@ -22,6 +22,7 @@ data OPMLState = OPMLState{
2222 , opmlDocTitle :: Inlines
2323 , opmlDocAuthors :: [Inlines]
2424 , opmlDocDate :: Inlines
25+ , opmlOptions :: ReaderOptions
2526 } deriving Show
2627
2728instance Default OPMLState where
@@ -29,13 +30,14 @@ instance Default OPMLState where
2930 , opmlDocTitle = mempty
3031 , opmlDocAuthors = []
3132 , opmlDocDate = mempty
32− }
33+ , opmlOptions = def
34+ }
3335
3436readOPML :: PandocMonad m => ReaderOptions -> Text -> m Pandoc
35−readOPML _ inp = do
37+readOPML opts inp = do
3638 (bs, st') <- runStateT
3739 (mapM parseBlock $ normalizeTree $
38− parseXML (unpack (crFilter inp))) def
40+ parseXML (unpack (crFilter inp))) def{ opmlOptions = opts }
3941 return $
4042 setTitle (opmlDocTitle st') $
4143 setAuthors (opmlDocAuthors st') $
@@ -69,13 +71,16 @@ attrValue attr elt =
6971-- exceptT = either throwError return
7072
7173asHtml :: PandocMonad m => String -> OPML m Inlines
72−asHtml s =
73− (\(Pandoc _ bs) -> case bs of
74− [Plain ils] -> fromList ils
75− _ -> mempty) <$> lift (readHtml def (pack s))
74+asHtml s = do
75+ opts <- gets opmlOptions
76+ Pandoc _ bs <- readHtml def{ readerExtensions = readerExtensions opts } (pack s)
77+ return $ fromList $ blocksToInlines bs
7678
7779asMarkdown :: PandocMonad m => String -> OPML m Blocks
78−asMarkdown s = (\(Pandoc _ bs) -> fromList bs) <$> lift (readMarkdown def (pack s))
80+asMarkdown s = do
81+ opts <- gets opmlOptions
82+ Pandoc _ bs <- readMarkdown def{ readerExtensions = readerExtensions opts } (pack s)
83+ return $ fromList bs
7984
8085getBlocks :: PandocMonad m => Element -> OPML m Blocks
8186getBlocks e = mconcat <$> mapM parseBlock (elContent e)
test/command/4164.mdnew file+35
@@ -0,0 +1,35 @@
1+```
2+% pandoc -f opml -t markdown
3+<?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:&#xA;&#xA;&lt;div&gt; &#xA;&lt;balise&gt;&#xA;bla bla&#xA;&lt;/div&gt;"/> </outline> </body> </opml>
4+^D
5+test
6+====
7+
8+try
9+---
10+
11+Here is inline html:
12+
13+<div>
14+
15+<balise> bla bla
16+
17+</div>
18+
19+```
20+
21+```
22+% pandoc -f opml-raw_html-native_divs -t markdown
23+<?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:&#xA;&#xA;&lt;div&gt; &#xA;&lt;balise&gt;&#xA;bla bla&#xA;&lt;/div&gt;"/> </outline> </body> </opml>
24+^D
25+test
26+====
27+
28+try
29+---
30+
31+Here is inline html:
32+
33+\<div\> \<balise\> bla bla \</div\>
34+
35+```