Don't escape < in <style> tags with --self-contained.

Closes #422: highlighting lost using `--self-contained`.
This commit is contained in:
John MacFarlane
2012-02-17 10:44:46 -08:00
parent 7376d26c36
commit 5914ae1ea3
2 changed files with 22 additions and 4 deletions
+10 -2
View File
@@ -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
+12 -2
View File
@@ -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" }