-
Notifications
You must be signed in to change notification settings - Fork 241
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
Allow modifying the text in broken_link_callback
#466
Comments
The callback functionality is due for an overhaul. We'll take this use-case into consideration for the new design! |
I'm currently working on the redesign, and wondered why you couldn't just set the title itself here. Wouldn't |
Right, but that requires action from the user, rustdoc can't do it itself. |
Ok, I understand. Thanks. |
After some more exploration, I've found that this would be pretty tough to implement in the parser. The main complication is that link contents can be an arbitrary tree of inline nodes, including images. So we cannot just pass along a mutable reference to a text buffer for the callback to edit. One solution would be to specialize for the case where the content is just text, but that seems like too much complexity to push onto other users just to support this use-case. Luckily, I believe there is another solution which doesn't require changes in the parser. You can create a custom iterator over the events that filters link events that were inserted by the callback (you can recognize these by their Please ket me know whether this would solve your problem. I can flesh out the implementation a bit more if that would help. |
Interesting, that seems like it might work. Actually a lot of the issues marked as 'S-blocked' on pulldown would probably be solved by a similar strategy. I'll close this since now I just have to figure out how to implement it in rustdoc 😆 |
Thanks for the help! |
Figured it out :) rust-lang/rust#76078 Thanks again! |
Use case: rustdoc wants to turn
[type@char]
into<a href="https://doc.rust-lang.org/std/primitive.char.html>char</a>
. But thebroken_link_callback
API doesn't allow for changing the text of a link, only the title that shows up when you hover.See also rust-lang/rust#65354, especially my comments around rust-lang/rust#65354 (comment).
I'd try to implement this myself, but my last try went ... poorly.
The text was updated successfully, but these errors were encountered: