readme_renderer
readme_renderer copied to clipboard
Add values to "rel" instead of overwriting existing ones
Hello,
let me start with an example.
<a href="https://fosstodon.org/@backintime" rel="me">foobar</a>
This input is transformed into this, with an overwritten rel-attribute:
<a href="https://fosstodon.org/@backintime" rel="nofollow">foobar</a>
But what I want is
<a href="https://fosstodon.org/@backintime" rel="me nofollow">foobar</a>
https://github.com/pypa/readme_renderer/blob/71f7cba4ee4a7009f4c4b2fb9b878e2704481bde/readme_renderer/clean.py#L79-L85
Background
I am aware that you use hn3 package for this. I asked there and got the answer that there is not option on the side of hn3 to modify that behavior. https://github.com/messense/nh3/issues/71
The broader picture here is that I need verify a mailman3 list on Mastodon. To make this happen the list landing page in mailman3 need to contain a rel=me link like you see above.
Approach
I can imagine a regex based approach/workaround and would provide a PR if you accept the concept of the solution. What do you think?
The approach described in short steps:
- Before calling hn3.clean() record (via regex) all a-tags (and if you want link-tags contain in head-tags) containing a "rel" attribute.
- Call hn3.clean()
- Iterate over the recorded cases
- Use their hn3.clean() version to find them in the sanitized HTML.
- Add the old rel-values to the rel-attribute.
What do you think?