Closed alexkutsan closed 1 year ago
i think you can try at least 2 ways, not checked btw:
puts Lexbor::Parser.new(BODY).css("mytag").size
puts Lexbor::Parser.new(BODY).root!.scope.select { |tag| tag.tag_name_slice == "mytag".to_slice }.size
this is not bug, just implementation aspect of nodes method.
Thanks! Is root!
/css considered as public field? I mean won't it be deleted within next minor version
yes
Hi, thanks for such a wonderful wrapper on top of lexbor.
There is a question regarding custom HTML tags. Looks like it does not support searching or custom tags in the html document: The code
raises
Unknown tag "mytag"
exception from https://github.com/kostya/lexbor/blob/41a929d34b1dc799de2753f3273ff9e26f38c145/src/lexbor/utils/tag_converter.cr#L51Looks like because nodes that allowed to search are limited to enum TagIdT https://github.com/kostya/lexbor/blob/master/src/lexbor/lib/constants.cr#L4
Adding new value to this enum does not help unfortunately - exception is gone, but node still does not appear in results o
nodes
funcitonIs there some other approach to iterate through custom nodes? or it is a limitation of original lexbor C implementation?
I have tried lexbor C implementation roughly and looks like it is able to extract custom nodes from HTML: