From 0a897a1de2316b6c02dffaff38a8cb3e66769d1e Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Sun, 16 Jun 2019 16:31:09 +1200 Subject: [PATCH] Implement interpretor support exists and locale attribute tests. --- src/Stylish/Style/Interpret.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Stylish/Style/Interpret.hs b/src/Stylish/Style/Interpret.hs index d034ecb..0c7f0ed 100644 --- a/src/Stylish/Style/Interpret.hs +++ b/src/Stylish/Style/Interpret.hs @@ -36,6 +36,7 @@ lowerInner (Property name test:s) = (tag, (name, compileAttrTest test):tail) where (tag, tail) = lowerInner s lowerInner [] = (Nothing, []) +compileAttrTest Exists = matched compileAttrTest (Equals val) = (== (unpack val)) compileAttrTest (Suffix val) = isSuffixOf $ unpack val compileAttrTest (Prefix val) = isPrefixOf $ unpack val @@ -73,4 +74,4 @@ testAttr expected test next attrs@(Attribute name value : attrs') testAttr _ _ _ [] = False hasWord expected value = expected `elem` words value -hasLang _ _ = False -- TODO add support for this. +hasLang expected value = expected == value || isPrefixOf (expected ++ "-") value -- 2.30.2