Fix issue with tagsoup renderTags

This commit is contained in:
Jasper Van der Jeugt 2013-01-20 15:51:23 +01:00
parent 064128305e
commit 87735f9778
4 changed files with 26 additions and 7 deletions

View file

@ -1,5 +1,5 @@
Name: hakyll
Version: 4.1.0.0
Version: 4.1.1.0
Synopsis: A static website compiler library
Description:
@ -176,9 +176,9 @@ Test-suite hakyll-tests
Build-Depends:
HUnit >= 1.2 && < 1.3,
QuickCheck >= 2.4 && < 2.6,
test-framework >= 0.4 && < 0.7,
test-framework-hunit >= 0.2 && < 0.3,
test-framework-quickcheck2 >= 0.2 && < 0.3,
test-framework >= 0.4 && < 0.9,
test-framework-hunit >= 0.2 && < 0.4,
test-framework-quickcheck2 >= 0.2 && < 0.4,
-- Copy pasted from hakyll dependencies:
base >= 4 && < 5,
binary >= 0.5 && < 0.7,

View file

@ -24,6 +24,7 @@ module Hakyll.Web.Html
import Data.Char (digitToInt, intToDigit,
isDigit, toLower)
import Data.List (isPrefixOf)
import qualified Data.Set as S
import System.FilePath (joinPath, splitPath,
takeDirectory)
import Text.Blaze.Html (toHtml)
@ -71,13 +72,20 @@ withUrls f = withTags tag
attr (k, v) = (k, if isUrlAttribute k then f v else v)
-- | Customized TagSoup renderer. (The default TagSoup renderer escape CSS
-- within style tags.)
--------------------------------------------------------------------------------
-- | Customized TagSoup renderer. The default TagSoup renderer escape CSS
-- within style tags, and doesn't properly minimize.
renderTags' :: [TS.Tag String] -> String
renderTags' = TS.renderTagsOptions TS.renderOptions
{ TS.optRawTag = (`elem` ["script", "style"]) . map toLower
, TS.optMinimize = (`elem` ["br", "img"])
, TS.optMinimize = (`S.member` minimize) . map toLower
}
where
-- A list of elements which must be minimized
minimize = S.fromList
[ "area", "br", "col", "embed", "hr", "img", "input", "meta", "link"
, "param"
]
--------------------------------------------------------------------------------

View file

@ -36,6 +36,10 @@ tests = testGroup "Hakyll.Web.Html.Tests" $ concat
withUrls id "<code>&lt;stdio&gt;</code>"
, "<style>body > p { line-height: 1.3 }</style>" @=?
withUrls id "<style>body > p { line-height: 1.3 }</style>"
-- Test minimizing elements
, "<meta bar=\"foo\" />" @=?
withUrls id "<meta bar=\"foo\" />"
]
, fromAssertions "toUrl"

View file

@ -2,6 +2,13 @@
title: Releases
---
## Hakyll 4.1.1.0
*January 20, 2013*
- Fix an issue regarding `relativizeUrls` expanding `<meta />` to
`<meta></meta>`
## Hakyll 4.1.0.0
*January 20, 2013*