~alcinnz/haskell-stylist

fec99b19a7ca7886471d2e5554b7a1e21dbb2c98 — Adrian Cochrane 3 years ago aa17d3d
Add support for `@document regexp()`..
2 files changed, 8 insertions(+), 3 deletions(-)

M src/Data/CSS/Preprocessor/Conditions.hs
M stylist.cabal
M src/Data/CSS/Preprocessor/Conditions.hs => src/Data/CSS/Preprocessor/Conditions.hs +4 -0
@@ 21,6 21,7 @@ import Data.Text.Internal (Text(..))
import Data.Text (unpack)
import Network.URI (URI(..), URIAuth(..), parseURI)
import Control.Concurrent.Async (forConcurrently)
import Text.Regex.TDFA ((=~))

import Data.List



@@ 85,6 86,9 @@ instance PropertyParser p => StyleSheet (ConditionalStyles p) where
        | isUnstyled self = parseAtBlock self toks
        | otherwise = addAtRule self "document" toks
    -- TODO Support regexp() conditions, requires new dependency
    addAtRule self "document" (Function "regexp":String pattern:RightParen:toks)
        | hostUrlS self =~ unpack pattern = parseAtBlock self toks
        | otherwise = addAtRule self "document" toks
    addAtRule self "document" tokens = (self, skipAtRule tokens)

    addAtRule self "media" toks

M stylist.cabal => stylist.cabal +4 -3
@@ 10,7 10,7 @@ name:                stylist
-- PVP summary:      +-+------- breaking API changes
--                   | | +----- non-breaking API additions
--                   | | | +--- code changes with no API change
version:             2.2.0.0
version:             2.3.0.0

-- A short (one-line) description of the package.
synopsis:            Apply CSS styles to a document tree.


@@ 70,7 70,8 @@ library
  -- Other library packages from which modules are imported.
  build-depends:       base >=4.9 && <=4.12, css-syntax >=0.1 && <0.2, text,
                        unordered-containers >= 0.2 && <0.3, hashable,
                        network-uri >= 2.6 && <2.7, async >= 2.1 && <2.3
                        network-uri >= 2.6 && <2.7, async >= 2.1 && <2.3,
                        regex-tdfa >= 1.3
  
  -- Directories containing source files.
  hs-source-dirs:      src


@@ 89,5 90,5 @@ test-suite test-stylist
  build-depends:       base >=4.9 && <=4.12, css-syntax >=0.1 && <0.2, text,
                        unordered-containers >= 0.2 && <0.3, hashable,
                        network-uri >= 2.6 && <2.7, async >= 2.1 && <2.3, hspec, QuickCheck,
                        scientific >= 0.3 && <1.0
                        scientific >= 0.3 && <1.0, regex-tdfa >= 1.3
  ghc-options: -Wall