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

Save source code ElementRef::html() #143

Closed
BlackSoulHub opened this issue Sep 7, 2023 · 3 comments
Closed

Save source code ElementRef::html() #143

BlackSoulHub opened this issue Sep 7, 2023 · 3 comments
Labels
C-question A question about the library.

Comments

@BlackSoulHub
Copy link

The string obtained from html(), although equivalent for html markup, is not such in the case of a string.
Example:

<table cellspacing="1" border="0" width="100%" class="inf">
// content
</table>

and

<table border="0" class="inf" cellspacing="1" width="100%">
// content
</table>

These 2 lines are equivalent for HTML markup, but they are not suitable for the case of comparing strings (or hashes).
Is it possible to change this? Or is there some good option to do this (preferably without using regex)?

@adamreichold
Copy link
Contributor

The internal TreeSink by which this crate integrates with the html5ever HTML does not transport the actual source text and/or positions, so we cannot reproduce them.

You can enable the deterministic feature of this crate to retain the order of the attributes, but this is not the only thing that could change compared to the source text, i.e. to ensure comparing/hashing strings yields stable results.

@BlackSoulHub
Copy link
Author

You can enable the deterministic feature of this crate

Thank you! I'll try to do that later.

but this is not the only thing that could change compared to the source text

Give me a hint. What else can change and what should be paid attention to.

@BlackSoulHub
Copy link
Author

Can be considered closed. The answer above worked for me.

@teymour-aldridge teymour-aldridge added the C-question A question about the library. label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-question A question about the library.
Projects
None yet
Development

No branches or pull requests

3 participants