garden icon indicating copy to clipboard operation
garden copied to clipboard

String parsing

Open WorldsEndless opened this issue 6 years ago • 1 comments

After searching the issues, wiki, and readme, I don't see this feature, which would be a tremendous step in the direction of increasing compatibility and making Garden more eco-friendly: The ability to paste in existing plain CSS (e.g. at a repl) and having it produce an equivalent Garden data structure. Philosophically this seems like a very Clojure-type thing to do, and it would also do wonders for the major use cases of 1) those with existing sizable CSS codebases they are concerned with moving to Garden, and 2) Those who want to grab online snippets and insert them easily into their projects.

I'm sure this is a no-brainer and has been discussed before, and I'd be willing to work on it but only if no one knows of a project working on this already.

Resources to grok:

  • https://www.w3.org/TR/CSS21/grammar.html
  • https://www.w3.org/TR/css-syntax-3/
  • https://developer.mozilla.org/en-US/docs/Web/CSS/CSS3

WorldsEndless avatar Jan 03 '18 16:01 WorldsEndless

Yes. This is something we can tackle on the branch #123 is tied to or we can do this post #123 merge. Because v2.0.0 parses "Garden syntax" into an AST the underlying AST will be the target of any string parser. This gives us parity between parsing and unparsing (compiling). I'm hesitant to take on additional dependencies but in this case it might be warranted to draw on instaparse.

noprompt avatar Jan 04 '18 21:01 noprompt