git.iko.soy/typeable/pandoc
on master help sign in
Don't escape `<` in `<style>` tags with `--self-contained`.

Closes #422: highlighting lost using `--self-contained`.

commit5914ae1ea3767541797e57d5cd08db1e27aabfc8 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 17 Feb 2012, 10:44 (15 years ago) parent7376d26
2 files changed+22−4
src/Text/Pandoc/Readers/HTML.hs+10−2 src/Text/Pandoc/SelfContained.hs+12−2
src/Text/Pandoc/Readers/HTML.hs+10−2
@@ -46,7 +46,7 @@ import Text.Pandoc.Shared
4646import Text.Pandoc.Parsing
4747import Data.Maybe ( fromMaybe, isJust )
4848import Data.List ( intercalate )
49−import Data.Char ( isSpace, isDigit )
49+import Data.Char ( isSpace, isDigit, toLower )
5050import Control.Monad ( liftM, guard, when )
5151
5252-- | Convert HTML-formatted string to 'Pandoc' document.
@@ -90,9 +90,17 @@ block = choice
9090 , pRawHtmlBlock
9191 ]
9292
93+-- repeated in SelfContained -- consolidate eventually
9394renderTags' :: [Tag String] -> String
9495renderTags' = 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" }
96104
97105pList :: TagParser [Block]
98106pList = pBulletList <|> pOrderedList <|> pDefinitionList
src/Text/Pandoc/SelfContained.hs+12−2
@@ -157,6 +157,16 @@ makeSelfContained :: Maybe FilePath -> String -> IO String
157157makeSelfContained userdata inp = do
158158 let tags = parseTags inp
159159 out' <- mapM (convertTag userdata) tags
160− return $ renderTagsOptions renderOptions{ optMinimize = (\t -> t == "br"
161− || t == "img" || t == "meta" || t == "link" ) } out'
160+ return $ renderTags' out'
162161
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" }