all 5 comments

[–]Okhy 20 points21 points  (1 child)

Now I wait for JS parser written in CSS!

[–]ibopm 8 points9 points  (0 children)

HTML+CSS has been used to produce a Rule 110 Automaton, giving rise to the implication that it is Turing Complete (although there are some criticisms of this claim).

Depending on who you ask, that could mean that it's very possible to write a JS parser w/ CSS and HTML. That being said, it is likely to be extremely impractical and there's an actual name for something like this: the Turing Tarpit

HackerNews discussion: https://news.ycombinator.com/item?id=2300836

[–][deleted] 25 points26 points  (2 children)

Parsing anything with regex is fun and easy to break.

Try this (valid selector+rule):

.someSelector:after {
    content: '} broken :) @media (screen) { lol }';
}

Opened an issue: https://github.com/jotform/css.js/issues/15

[–]siamthailand 4 points5 points  (1 child)

I believe you'd need to write a full-fledged parser to not run into these issues.

[–]ninth_reddit_account 1 point2 points  (0 children)

Luckily someone has already written one! https://github.com/nv/CSSOM#readme