Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken link handler API is too inflexible #635

Open
ssokolow opened this issue Apr 6, 2023 · 2 comments
Open

Broken link handler API is too inflexible #635

ssokolow opened this issue Apr 6, 2023 · 2 comments

Comments

@ssokolow
Copy link

ssokolow commented Apr 6, 2023

Currently, the BrokenLinkCallback API only allows preventing a broken link from being rendered as a link or altering the URL and/or title.

In order to achieve the "apply a CSS class which colors broken links red" result I wanted, I had to resort to emitting :BROKEN_LINK: as the new URL and then using a second pass with quick-xml to filter that out and set class="broken_link".

@Martin1887
Copy link
Collaborator

This sounds interesting, but implementing it it's not trivial because currently links have not more attributes and events are completely separated from rendering.

A similar approach should be used for images and maybe even other HTML elements.

@ssokolow
Copy link
Author

I'm probably going to work around this without losing the original URL by replacing :BROKEN_LINK: with <original_url>#<uuid chosen at beginning of run> so that I can then check for and rsplit_once the #<uuid chosen at beginning of run> suffix in my postprocessing (now using lol-html) without worring about name collisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants