@@ 11,6 11,7 @@ import System.Directory as Dir
import Data.FileEmbed
import Data.Maybe (fromMaybe, maybeToList)
+import Text.Read (readMaybe)
import Debug.Trace (trace)
--- External Rhapsode subcomponents
@@ 108,6 109,19 @@ loadUserStyles styles = do
targetSel "" = [CSSTok.Ident "main"]
targetSel "#" = [CSSTok.Colon, CSSTok.Ident "root"]
+targetSel ('#':'.':anchor) =
+ CSSTok.Colon : CSSTok.Ident "root" : concat [ selLayer n | n <- path anchor]
+ where
+ path ('.':anchor) = [] : path anchor
+ path (c:anchor) | n:path' <- path anchor, c >= '0' && c <= '9' = (c:n):path'
+ path [] = [[]]
+ path _ = []
+
+ selLayer n = [
+ CSSTok.Delim '>',
+ CSSTok.Colon, CSSTok.Function "nth-child",
+ CSSTok.Number (pack n) (CSSTok.NVInteger $ fromMaybe 0 $ readMaybe n),
+ CSSTok.RightParen]
targetSel ('#':id) = [CSSTok.Hash CSSTok.HUnrestricted $ Txt.pack id]
targetSel _ = []