lycheeverse / lychee

⚡ Fast, async, stream-based link checker written in Rust. Finds broken URLs and mail addresses inside Markdown, HTML, reStructuredText, websites and more!
https://lychee.cli.rs
Apache License 2.0
2.22k stars 134 forks source link

feature request: check text fragments #1545

Open SKalt opened 4 weeks ago

SKalt commented 4 weeks ago

Text fragments are a standardized way to link to webpage text without relying on HTML ID attributes. They are supported by all modern browsers. I'd like to use lychee to make sure my text fragment links are valid!

Example:

<!-- file.html -->
<html>
  <body>
    <div>
      <a href="https://developer.mozilla.org/en-US/docs/Web/URI/Fragment/Text_fragments#:~:text=without%20relying%20on%20the%20presence%20of%20IDs">
        valid
      </a>
      <a href="https://developer.mozilla.org/en-US/docs/Web/URI/Fragment/Text_fragments#:~:text=asdfawefaweafa">
        invalid
      </a>
    </div>
  </body>
</html>
; lychee --version
# lychee 0.16.1
; lychee -vv --include-fragments ./file.html
#     [200] https://developer.mozilla.org/en-US/docs/Web/URI/Fragment/Text_fragments#:~:text=without%20relying%20on%20the%20presence%20of%20IDs
#     [200] https://developer.mozilla.org/en-US/docs/Web/URI/Fragment/Text_fragments#:~:text=asdfawefaweafa

Desired behavior: if lychee is configured to check fragments and is passed a #:~:text=... fragment, lychee should throw an error if the text is not found within the linked document.

mre commented 4 weeks ago

@HU90m, this one has your name on it. 😆