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

html_declaration can be a 2 tuple #399

Closed derek-zhou closed 2 years ago

derek-zhou commented 2 years ago

Description

According to the doc, html_declaration is a 3 tuple like:

@type html_declaration() :: {:pi, String.t(), [html_attribute()]}

However, I've encounter a {:pi, String.t()} 2 tuple. Reading the code a bit, this is actually intentional:

https://github.com/philss/floki/blob/d3fc8dada223eebfb1631164182e465d59836ca7/src/floki_mochi_html.erl#L351

<?php is broken html but unfortunately exists in the wild; most people would be happy if they do not exist. May I suggest to change this 2 tuple into a 3 tuple with a empty html_attribute list, so it is consistent with the documentation?

philss commented 2 years ago

@derek-zhou makes sense to me. Please go ahead if you want to open a PR :+1: