aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-08-15 09:42:16 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-08-15 09:42:16 -0700
commita6f2b960844caa81d9c8dd4d18f94c3de50bdb49 (patch)
tree870db6b2655d372fddffdd87f5d8f848e43812cd /src/Text/Pandoc/Readers
parent3745706fa2b2ada40126e59d3fa354f3f72efee9 (diff)
downloadpandoc-a6f2b960844caa81d9c8dd4d18f94c3de50bdb49.tar.gz
Moved renderTags' from HTML reader & SelfContained to Shared.
Improved removal of markdown="1" attribute in Markdow reader.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs14
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs12
2 files changed, 10 insertions, 16 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 33846286d..e5c310ffc 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -45,7 +45,7 @@ import Text.Pandoc.Options
import Text.Pandoc.Parsing
import Data.Maybe ( fromMaybe, isJust )
import Data.List ( intercalate )
-import Data.Char ( isDigit, toLower )
+import Data.Char ( isDigit )
import Control.Monad ( liftM, guard, when, mzero )
isSpace :: Char -> Bool
@@ -95,18 +95,6 @@ block = choice
, pRawHtmlBlock
]
--- repeated in SelfContained -- consolidate eventually
-renderTags' :: [Tag String] -> String
-renderTags' = renderTagsOptions
- renderOptions{ optMinimize = \x ->
- let y = map toLower x
- in y == "hr" || y == "br" ||
- y == "img" || y == "meta" ||
- y == "link"
- , optRawTag = \x ->
- let y = map toLower x
- in y == "script" || y == "style" }
-
pList :: TagParser [Block]
pList = pBulletList <|> pOrderedList <|> pDefinitionList
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index fe9be439e..b0925ac68 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -776,11 +776,10 @@ rawHtmlBlocks = do
if "markdown" `notElem`
map fst as
then mzero
- else return $ substitute
- " markdown=\"1\"" "" raw
+ else return $
+ stripMarkdownAttribute raw
| otherwise -> return raw
_ -> return raw )
- -- TODO remove markdown="1" attribute from raw tags
sps <- do sp1 <- many spaceChar
sp2 <- option "" (blankline >> return "\n")
sp3 <- many spaceChar
@@ -793,6 +792,13 @@ rawHtmlBlocks = do
let combined = concat htmlBlocks
return $ if last combined == '\n' then init combined else combined
+-- remove markdown="1" attribute
+stripMarkdownAttribute :: String -> String
+stripMarkdownAttribute s = renderTags' $ map filterAttrib $ parseTags s
+ where filterAttrib (TagOpen t as) = TagOpen t
+ [(k,v) | (k,v) <- as, k /= "markdown"]
+ filterAttrib x = x
+
--
-- Tables
--