pulldown-cmark icon indicating copy to clipboard operation
pulldown-cmark copied to clipboard

Broken link handler API is too inflexible

Open ssokolow opened this issue 2 years ago • 2 comments

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".

ssokolow avatar Apr 06 '23 11:04 ssokolow

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.

Martin1887 avatar May 07 '23 09:05 Martin1887

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.

ssokolow avatar May 16 '24 02:05 ssokolow