pytest-check-links icon indicating copy to clipboard operation
pytest-check-links copied to clipboard

Include line number in report of failed link.

Open reagle opened this issue 5 years ago • 6 comments
trafficstars

It'd be nice if it included the line number in the report of failed link.

reagle avatar Sep 10 '20 14:09 reagle

Hi @reagle! I not sure if this is possible since we convert the documents to html prior to checking the links. The actual link url might not even be in the original document.

blink1073 avatar Sep 11 '20 15:09 blink1073

Ah, I see. I appreciate that this worked on markdown but I can see the problem. I was hoping I could set a pattern in iTerm such that clicking on it opened it in my editor (as I do with Python exceptions) or could even use in my editor (as I do with linting). How do you do the conversion?

reagle avatar Sep 11 '20 15:09 reagle

We do the conversion here and then parse the document here. We might be able to get the line number from the parsed html, but at that point we don't know what type the original document was.

blink1073 avatar Sep 11 '20 15:09 blink1073

The only hack I can think of is to preprocess the markdown line number as an attribute prior to conversion. Using pandoc's syntax for link attributes, something like:

""" image{#id .class width=30 height=20px ln=23} """

A more generic approach would to be use something like pandoc to parse the AST and check link types there. The new commonmark parser in commonmark-hs is supposed to have source information which could yield line numbers....?

reagle avatar Sep 11 '20 16:09 reagle

I don't have the bandwidth to work on this, but would support something along these lines.

blink1073 avatar Sep 11 '20 17:09 blink1073

Fair enough. I'm not prepared to take this on myself.

reagle avatar Sep 11 '20 19:09 reagle