tats/w3m

Displaying accurate link numbers

Closed this issue · 2 comments

The "display link numbers option" does not number/count links accurately on some pages. Calling LINK_BEGIN can navigate to the incorrect link.

Steps to reproduce:

In configuration set display_link_numbers 1. Open a page with urls inside anchor tags and urls inside not inside anchor tags. On this example page, https://linuxconf.org, and https://google.com are not given a visible link number when display_link_number is toggled on. But these links are counted by, and can be jumped to using LINK_BEGIN or LINK_END.

linkNumbers

In the image, 17 LINK_BEGIN, 18 LINK_BEGIN, 19 LINK_BEGIN jump to the two linuxconfig strings and google url string respectively. But these numbers are associated with links further down the page.

I'm not keenly familiar with html. But it looks like getLinkNumberStr() needs to be called for those omitted links to be given a number. This probably takes place inside HTMLtagproc1()? Are the links in the provided example being skipped because the links are inside a table, and getLinkNumberStr() isn't being called for that specific switch case? That function is fairly large, and my understanding limited. If someone would be kind enough to point me in the right direction, I probably could figure the rest out. Thank you.

rkta commented

Looks like you have 'Treat URL-like strings as links in all pages' set to YES.

I didn't realize I had this toggled.

The problem here is, that the conversion to a link happens after creating the buffer when the insertion of the link numbers is already done. I already did an attempt to fix this, but it turned out to be more complicated than I initially thought. The function that converts the links is chkURLBuffer.

I appreciate the explanation. I was implementing link hints (#188) when I came across the behavior. Setting the marks option to "off" gets me the behavior I need while writing that feature. Thanks.