aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-02-17 10:44:46 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-02-17 10:44:46 -0800
commit5914ae1ea3767541797e57d5cd08db1e27aabfc8 (patch)
tree693d029874c5c590d1286ed29b6b9650ebdaf9c2 /src/Text/Pandoc
parent7376d26c364826f2ef689f5c7040016369e0a558 (diff)
downloadpandoc-5914ae1ea3767541797e57d5cd08db1e27aabfc8.tar.gz
Don't escape `<` in `<style>` tags with `--self-contained`.
Closes #422: highlighting lost using `--self-contained`.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs12
-rw-r--r--src/Text/Pandoc/SelfContained.hs14
2 files changed, 22 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 43165ceb1..0c017b2e4 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -46,7 +46,7 @@ import Text.Pandoc.Shared
import Text.Pandoc.Parsing
import Data.Maybe ( fromMaybe, isJust )
import Data.List ( intercalate )
-import Data.Char ( isSpace, isDigit )
+import Data.Char ( isSpace, isDigit, toLower )
import Control.Monad ( liftM, guard, when )
-- | Convert HTML-formatted string to 'Pandoc' document.
@@ -90,9 +90,17 @@ block = choice
, pRawHtmlBlock
]
+-- repeated in SelfContained -- consolidate eventually
renderTags' :: [Tag String] -> String
renderTags' = renderTagsOptions
- renderOptions{ optMinimize = (`elem` ["hr","br","img"]) }
+ 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/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
index 9c609b8fe..9332a3fa0 100644
--- a/src/Text/Pandoc/SelfContained.hs
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -157,6 +157,16 @@ makeSelfContained :: Maybe FilePath -> String -> IO String
makeSelfContained userdata inp = do
let tags = parseTags inp
out' <- mapM (convertTag userdata) tags
- return $ renderTagsOptions renderOptions{ optMinimize = (\t -> t == "br"
- || t == "img" || t == "meta" || t == "link" ) } out'
+ return $ renderTags' out'
+-- repeated from HTML reader:
+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" }