lychee icon indicating copy to clipboard operation
lychee copied to clipboard

Feature request: Line numbers and columns in output

Open mihaigalos opened this issue 2 years ago • 6 comments

Hi,

Awesome stuff!

Can you please support line numbers in the output? - ideally they can come immediately after a colon after the filename (i.e.: [./README.md:123:54]: - this enables easy access to the file on line 123, column 54 via other editors.

mihaigalos avatar Nov 21 '23 21:11 mihaigalos

Unfortunately, that is not possible due to limitations of the underlying libraries, namely https://github.com/servo/html5ever/issues/48 and https://github.com/untitaker/html5gum/issues/10. I think you need to try your luck there first. 😕 pulldown-cmark supports spans already and the plaintext library, linkify, supports it, too. So the issue is with the HTML libraries at the moment. You could add a comment in the linked issues.

mre avatar Nov 25 '23 01:11 mre

If I understand this correctly, lychee creates a list of URLs to test, makes an async call to servo which then test if they're up or not. You're implying that servo should return both the line number and the status of the link.

I think they should be separate, and lychee should know the line number for a URL which is up or down.

This separates concerns cleanly: servo, a web broser engine should not care about the line number in a file that produced the URL it needs to check. That is part of the presentation layer in the actuall app - lychee.

mihaigalos avatar Nov 25 '23 08:11 mihaigalos

If I understand this correctly, lychee creates a list of URLs to test, makes an async call to servo which then test if they're up or not.

Not quite. lychee uses servo's html parser, html5ever, to extract URLs and makes an async call with reqwest, a http client, to test if they are up or not.

html5ever does not return the line number. That information is lost and there is no way to get the line numbers except for parsing the html in some other way. As far as I'm aware, there currently is no html parser in Rust that gives me line numbers (or spans to be precise).

mre avatar Nov 30 '23 11:11 mre

Closing this as there is currently no way to support this feature due to upstream crate limitations. We can revisit at a later point in case the tools support it.

mre avatar Jan 05 '24 20:01 mre

html5gum 0.8.0 supports this feature thanks to @akida31, so it could be integrated in lychee now

untitaker avatar Aug 15 '25 13:08 untitaker

With merging #1870 we are now a big step closer to complete this. @Akida31 implemented span extraction in lychee-lib. So now we only need to make use of the newly introduced RawUriSpan in lychee-bin and show them to users. This should be fairly easy compared to the extraction itself. So any contributions are appreciated.

thomas-zahner avatar Oct 10 '25 09:10 thomas-zahner