~alcinnz/haskell-stylist

62b97a58ccc092501926b2946d02808fd3de2f90 — Adrian Cochrane 5 years ago 932c358
Fix incorrect handling of invalid syntaxes.
3 files changed, 9 insertions(+), 9 deletions(-)

M src/Data/CSS/Syntax/StyleSheet.hs
D src/Stylish.hs
M test/Test.hs
M src/Data/CSS/Syntax/StyleSheet.hs => src/Data/CSS/Syntax/StyleSheet.hs +2 -1
@@ 52,7 52,8 @@ parse' stylesheet tokens = parse' (addRules stylesheet rule) tokens'
--------
parseProperties (LeftCurlyBracket:tokens) = parseProperties' tokens
parseProperties (Whitespace:tokens) = parseProperties tokens
parseProperties (_:tokens) = ([], tokens)
-- This error recovery is a bit overly conservative, but it's simple.
parseProperties (_:tokens) = ([], skipAtRule tokens)
parseProperties [] = ([], [])

parseProperties' (Whitespace:tokens) = parseProperties' tokens

D src/Stylish.hs => src/Stylish.hs +0 -8
@@ 1,8 0,0 @@
module Stylish(
        parse,
        StyleSheet, addRule, addAtRule,
        StyleRule,
        Selector, Combinator, SimpleSelector, AttrTest
    ) where

import Stylish.Parse

M test/Test.hs => test/Test.hs +7 -0
@@ 270,6 270,13 @@ spec = do
            let rules = parse queryable "a {color: red;}"
            let TrivialPropertyParser style = cascade rules el [("color", [Ident "green"])] temp::TrivialPropertyParser
            style ! "color" `shouldBe` [Ident "green"]
    describe "Parser freezes" $ do
        it "does not regress" $ do
            -- TODO handle psuedoelements
            parse emptyStyle "output::before {content: 'Output'; pitch: high}"
                `shouldBe` TrivialStyleSheet [
                    StyleRule (Element [Tag "output"]) []
                ]

styleIndex :: StyleIndex
styleIndex = new