philss / floki

Floki is a simple HTML parser that enables search for nodes using CSS selectors.
https://hex.pm/packages/floki
MIT License
2.05k stars 155 forks source link

Suggestion self_closing_tags #405

Closed inoas closed 2 years ago

inoas commented 2 years ago

Feature goal

Would you be interested in a PR that made these configurable. They would stay like this unless someone overwrote some application layer config.

https://github.com/philss/floki/blob/61cd7126c3486c4f857fc7f7a82405dcabf25df0/lib/floki/raw_html.ex#L4-L21

Dependencies

None

inoas commented 2 years ago

I am using Floki to render UBB-style xml and there are tags like <pagelink/> or <media/> or

Edit:

Application.get_env(:floki, :append_self_closing_tags)
Application.get_env(:floki, :set_self_closing_tags)

Would need to be evaluated.

If this interestes you: Would you also prefer for this to be changable at runtime like the html parser is?

philss commented 2 years ago

@inoas this is good idea. Maybe :custom_self_closing_tags?

If this interestes you: Would you also prefer for this to be changable at runtime like the html parser is?

This would be nice as well!

inoas commented 2 years ago

OK, thanks for the go ahead, I will look to find some time to implement.

inoas commented 2 years ago

custom_self_closing_tags

The idea about :append_self_closing_tags and :set_self_closing_tags would be to either append to the ones currently set by default / by the developer... or to set them. set_self_closing_tags could also be put_self_closing_tags or replace_self_closing_tags.

This is up to you what you want here, just replacing or appending and replacing? Just let me know :)

philss commented 2 years ago

I personally don't see much use for replacing them entirely. Seems like only appending is enough.