git.iko.soy/typeable/pandoc
on master help sign in
Don't escape `<` in `<style>` tags with `--self-contained`.
5914ae1John MacFarlane
src/Text/Pandoc/Readers/HTML.hs+10−2
@@ -46,7 +46,7 @@ import Text.Pandoc.Shared
46import Text.Pandoc.Parsing
46import Text.Pandoc.Parsing
47import Data.Maybe ( fromMaybe, isJust )
47import Data.Maybe ( fromMaybe, isJust )
48import Data.List ( intercalate )
48import Data.List ( intercalate )
49−import Data.Char ( isSpace, isDigit )
49+import Data.Char ( isSpace, isDigit, toLower )
50import Control.Monad ( liftM, guard, when )
50import Control.Monad ( liftM, guard, when )
51
51
52-- | Convert HTML-formatted string to 'Pandoc' document.
52-- | Convert HTML-formatted string to 'Pandoc' document.
@@ -90,9 +90,17 @@ block = choice
90 , pRawHtmlBlock
90 , pRawHtmlBlock
91 ]
91 ]
92
92
93+-- repeated in SelfContained -- consolidate eventually
93renderTags' :: [Tag String] -> String
94renderTags' :: [Tag String] -> String
94renderTags' = renderTagsOptions
95renderTags' = renderTagsOptions
95− renderOptions{ optMinimize = (`elem` ["hr","br","img"]) }
96+ renderOptions{ optMinimize = \x ->
97+ let y = map toLower x
98+ in y == "hr" || y == "br" ||
99+ y == "img" || y == "meta" ||
100+ y == "link"
101+ , optRawTag = \x ->
102+ let y = map toLower x
103+ in y == "script" || y == "style" }
96
104
97pList :: TagParser [Block]
105pList :: TagParser [Block]
98pList = pBulletList <|> pOrderedList <|> pDefinitionList
106pList = pBulletList <|> pOrderedList <|> pDefinitionList
src/Text/Pandoc/SelfContained.hs+12−2
@@ -157,6 +157,16 @@ makeSelfContained :: Maybe FilePath -> String -> IO String
157makeSelfContained userdata inp = do
157makeSelfContained userdata inp = do
158 let tags = parseTags inp
158 let tags = parseTags inp
159 out' <- mapM (convertTag userdata) tags
159 out' <- mapM (convertTag userdata) tags
160− return $ renderTagsOptions renderOptions{ optMinimize = (\t -> t == "br"
160+ return $ renderTags' out'
161− || t == "img" || t == "meta" || t == "link" ) } out'
162
161
162+-- repeated from HTML reader:
163+renderTags' :: [Tag String] -> String
164+renderTags' = renderTagsOptions
165+ renderOptions{ optMinimize = \x ->
166+ let y = map toLower x
167+ in y == "hr" || y == "br" ||
168+ y == "img" || y == "meta" ||
169+ y == "link"
170+ , optRawTag = \x ->
171+ let y = map toLower x
172+ in y == "script" || y == "style" }