lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]





On Tue, May 27, 2014 at 5:47 AM, Bas Groothedde <lua@xoru.net> wrote:

On 27.05.2014 09:44, steve donovan wrote:

On Tue, May 27, 2014 at 5:06 AM, Coda Highland <chighland@gmail.com> wrote:
The good news is that CSS syntax is very simple -- I think it may even be a regular language. It should be pretty darn easy to write an lpeg parser for it.
Yep, also thought this is a job for Captain LPeg - although it's more
tricky than at first sight.

But, the question is, what parsed representation does the OP need, and
for what purpose?

I would need something like a hierarchical table in which I could lookup the specified CSS attributes and their values, so that I can extract them for specific elements and apply them in a non-HTML environment. It's for a customizable canvas-like drawing area.

If there currently are no parsers out there, I might have to accept my losses and go with something more limited and simplistic, and implement CSS parsing later on.

--

Bas Groothedde
Imagine Programming

I think I'm stating the obvious, but a parser might not be what you want. That is, a parser tell you if its proper syntax, but knowing what the scope of a property or a selector is for CSS is incredibly complicated, IMHO. It's something that I'd like to have some day as well. [1]
So... are you trying to answer: "This element has what attributes?" or "This CSS declaration applies to what?" or both? I guess those are two approaches to the same thing... How complete do you need to be?

-Andrew

[1]When I sit back and contemplate what that would take, it makes me have sympathy for web browser designers, which is something that I try not to have, given the pain and torture that was the status quo from 96-2011-ish.