Skip to content

Is it possible to get line/column number of a tag? #532

@yasoob

Description

@yasoob

Hi!

I am trying to find an HTML tokenizer for Elixir that can also provide me with line number of the matching tag. I see that floki_mochi_html has #decoder{offset} record and there are also references to INC_COL in the code base. I could have tried to extract this information on my own but I am not well-versed with Erlang. Do you think it is possible to expose this information from Floki?

This is probably going to require changes to the data structure. Maybe flat_parse could contain this additional information?

Please let me know if this is doable and even if this is not a good fit for Floki, I would love to hear your suggestions of how I could go about implementing this on my own.

Just for some added context, a sample usecase for this could be a tool using Floki that extracts all a tags and then lists their line numbers/location in the html document. My own usecase is a bit different but this one is a simpler representative example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions