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

Add common conversion traits for Node types. #2

Merged
merged 10 commits into from
Aug 3, 2023

Conversation

Conner-PYS
Copy link
Contributor

@Conner-PYS Conner-PYS commented Jul 31, 2023

Thanks for putting this library together! I've been testing it out over the last day or so and found myself wanting easier from/into conversions for some of the Node types and strings.

This PR adds the following impls:

  • on Node:

    • From<Comment>
    • From<Doctype>
    • From<Fragment>
    • From<Element>
    • From<Text>
    • From<UnsafeText>
  • on Comment, Doctype, Text, UnsafeText:

    • From<T: Into<String>>
  • Subsequent commits have reorganized the node types into separate sub-modules; the single file was becoming a little to bloated.

  • Also, added a pretty-printing wrapper behind a pretty feature-flag; this wrapper is always formatted with the alternate formatter.

Copy link
Owner

@vidhanio vidhanio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few notes, but these look extremely helpful for making the api easier to use, thank you very much for your contributions!

i apologize for not recognizing this pr sooner, i completely missed it in my github notifications.

html-node-core/src/node/unsafe_text.rs Outdated Show resolved Hide resolved
html-node/Cargo.toml Outdated Show resolved Hide resolved
html-node-core/src/node/doctype.rs Outdated Show resolved Hide resolved
@Conner-PYS
Copy link
Contributor Author

Conner-PYS commented Aug 2, 2023

Ok, I've added a new commit with the final update I need at the moment, which is better support for inserting CSS content. Check out the new style!() proc-macro and styling.rs example I added to the main crate. This macro is feature-flagged behind basic-css.

I've tried to make sure that all the relevant documentation has also been updated, but let me know if something isn't clear.

Version has been bumped to 0.3 so you can publish to crates.io without any further commits.

And no worries about missing the PR for a bit, we've all got lives!

@vidhanio
Copy link
Owner

vidhanio commented Aug 3, 2023

@Conner-PYS, would it be possible to move css changes to a new pr? there is some further discussion that would be had there, which I don't want blocking the conversion changes.

these css changes look great btw!

@Conner-PYS
Copy link
Contributor Author

Pulled the CSS macro out; I'll put up another PR with it soon. I'd love to hear if you have any ideas on improving the ergonomics of writing CSS in Rust tokens.

@Conner-PYS
Copy link
Contributor Author

CSS macro draft PR is here: #3

Simply reverts the last commit from this PR at the moment.

@vidhanio vidhanio merged commit 0e30fff into vidhanio:main Aug 3, 2023
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

Successfully merging this pull request may close these issues.

2 participants