Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support printing out JSON #18

Open
gabebw opened this issue Sep 3, 2019 · 0 comments
Open

Support printing out JSON #18

gabebw opened this issue Sep 3, 2019 · 0 comments

Comments

@gabebw
Copy link
Owner

gabebw commented Sep 3, 2019

Like pup: https://github.com/EricChiang/pup#json

Candle supports printing out information for multiple selectors (a {text}, link {text}, while Pup only prints information for one final selector. That makes printing out the JSON a bit weird, because then candle might print JSON mixed with text (e.g. a {json}, link {text}). Candle could let people do that, but it's very unlikely to be what people want. Let's enforce that {json} must be the final and only operator.

I think the JSON format should differ slightly from pup's in that it should always print out an array of objects, even if there's only one object.

Also maybe nice to have would be allowing it to filter to specific attributes, like div json{class}, which would print only the class for divs, and would not print the children at all. So given `

:

{
  "tag": "div",
  "attributes": [{ "class": "whatever" }],
  "children": []
}

To support that, the selector should be json{OPTIONAL_ATTRS}, not {json}, and thus {html} should probably be html{} too, for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant