Closed rinpatch closed 4 years ago
@rinpatch thank you for the suggestion. We had a contribution from @schneiderderek which added the two functions parse_document!
and parse_fragment!
which has the same behaviour you mentioned. It is available in version 0.25.0.
Feature goal
Floki 0.2.4 deprecated
Floki.parse
and functions that accepted html as binary. However it's not easy to migrate the code to new parse functions since they return an{:ok | :error, result}
tuple, which becomes a problem when you have used these functions in the middle of pipelines with a big number of steps. It also feels kinda useless withmochiweb_html
, which is probably what most people use, since it can't return an error when parsing the document.Hence, I think it would make sense to add unsafe versions of
Floki.parse_document
andFloki.parse_fragment
, which raise an exception on parse failure.Dependencies
I would use Unsafe, though it can be done manually just fine as well.