You will also need to customize the LinkHandlers. There is an example in the docs for how to add nofollow to all links. You will need to modify it to accept your dynamic attribute. https://docs.wagtail.org/en/stable/extending/rich_text_internals.html#registering-rewrite-handlers