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

Implement Inspect protocol for HTMLTree #547

Merged
merged 8 commits into from
Mar 23, 2024

Conversation

vittoriabitton
Copy link
Contributor

@vittoriabitton vittoriabitton commented Feb 28, 2024

No description provided.

@vittoriabitton vittoriabitton force-pushed the vb-implement-inspect-to-htmltree branch 2 times, most recently from c0c20d1 to ce4cf2f Compare February 28, 2024 15:53
@vittoriabitton vittoriabitton force-pushed the vb-implement-inspect-to-htmltree branch from f849b0b to 3a0eb98 Compare March 11, 2024 22:24
@vittoriabitton vittoriabitton force-pushed the vb-implement-inspect-to-htmltree branch from 5109def to 43b7829 Compare March 13, 2024 03:56
@vittoriabitton vittoriabitton changed the title [WIP] Implement Inspect protocol for HTMLTree Implement Inspect protocol for HTMLTree Mar 13, 2024
@vittoriabitton vittoriabitton marked this pull request as ready for review March 13, 2024 19:39
Copy link
Owner

@philss philss left a comment

Choose a reason for hiding this comment

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

This is looking great! 🎉

I added some refactoring suggestions :)

lib/floki/html_tree.ex Outdated Show resolved Hide resolved
lib/floki/html_tree.ex Outdated Show resolved Hide resolved
lib/floki/html_tree.ex Outdated Show resolved Hide resolved
Comment on lines 261 to 268
html_tree = %HTMLTree{
root_nodes_ids: [2, 1],
node_ids: [2, 1],
nodes: %{
1 => %Text{content: "hello", node_id: 1},
2 => %Text{content: " world", node_id: 2}
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

After thinking for a while, I believe the parser won't produce such tree, because the Text would be collapsed. So I would change this to one Text` node, or maybe adding a tag in between.

}

assert inspect(html_tree) ==
~s|%HTMLTree{<html>start of the stack<a class="link"><b>click me</b></a><span></span></html>}|
Copy link
Owner

Choose a reason for hiding this comment

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

We forgot to format the comment. The suggestions I made is changing that. But the output here will be different.

PS: try to add a |> dbg() to line 292 and see the beauty of the output :D

Copy link
Owner

@philss philss left a comment

Choose a reason for hiding this comment

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

Awesome!! :D
Thank you! 💜

test/floki/html_tree_test.exs Outdated Show resolved Hide resolved
test/floki/html_tree_test.exs Outdated Show resolved Hide resolved
@philss philss merged commit 39f4313 into philss:main Mar 23, 2024
9 checks passed
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