shakespeare-css 1.0.6.3 → 1.0.6.4
raw patch · 3 files changed
+47/−3 lines, 3 files
Files
- Text/IndentToBrace.hs +24/−2
- shakespeare-css.cabal +1/−1
- test/ShakespeareCssTest.hs +22/−0
Text/IndentToBrace.hs view
@@ -1,9 +1,11 @@+{-# LANGUAGE OverloadedStrings #-} module Text.IndentToBrace ( i2b ) where import Control.Monad.Trans.Writer (execWriter, tell, Writer)-import Data.List (isPrefixOf, isInfixOf)+import Data.List (isInfixOf)+import qualified Data.Text as T i2b :: String -> String i2b = ($ [])@@ -12,9 +14,29 @@ . map addClosingCount . nest . map toL+ . stripComments . lines . filter (/= '\r') +stripComments :: [String] -> [String]+stripComments =+ map T.unpack . go False . map T.pack+ where+ go _ [] = []++ go False (l:ls) =+ let (before, after') = T.breakOn "/*" l+ in case T.stripPrefix "/*" after' of+ Nothing -> l : go False ls+ Just after ->+ let (x:xs) = go True $ after : ls+ in before `T.append` x : xs+ go True (l:ls) =+ let (_, after') = T.breakOn "*/" l+ in case T.stripPrefix "*/" after' of+ Nothing -> T.empty : go True ls+ Just after -> go False $ after : ls+ data Line = Line { lineIndent :: Int , lineContent :: String@@ -47,7 +69,7 @@ toL :: String -> Either String Line toL s- | null y || "/*" `isPrefixOf` y = Left s+ | null y = Left s | otherwise = Right $ Line (length x) y where (x, y) = span (== ' ') s
shakespeare-css.cabal view
@@ -1,5 +1,5 @@ name: shakespeare-css-version: 1.0.6.3+version: 1.0.6.4 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>
test/ShakespeareCssTest.hs view
@@ -21,6 +21,8 @@ describe "shakespeare-css" $ do it "cassius" caseCassius it "cassiusFile" caseCassiusFile + it "cassius single comment" caseCassiusSingleComment + it "cassius leading comment" caseCassiusLeadingComment it "cassiusFileDebug" $ do let var = "var" @@ -540,6 +542,26 @@ , "bar:bar;color:#7F6405;fvarx:someval;unicode-test:שלום;" , "urlp:url(url?p=q)}" ] + +caseCassiusSingleComment :: Assertion +caseCassiusSingleComment = + flip celper [cassius| + /* + this is a comment + */ + |] "" + +caseCassiusLeadingComment :: Assertion +caseCassiusLeadingComment = + flip celper [cassius| + /* + this is a comment + */ + sel1 + foo: bar + sel2 + baz: bin + |] "sel1{foo:bar}sel2{baz:bin}" instance Show Url where show _ = "FIXME remove this instance show Url"