I found this very irritating. So, I came up with my own solution. This filters the content before it gets sent to the browser while leaving the stored version in the DB unchanged. I believe Rank Math needs the class for Gutenberg special link options. Win-win for both you and Rank Math.
if ( !function_exists('filter_the_content_remove_rank_math_link') ) {
/**
* Remove/filter `rank-math-link` class added by Rank Math
*
* @param $content
* @return string|string[]
*/
function filter_the_content_remove_rank_math_link( $content )
{
// Check if we're inside the single Post.
if ( is_singular() ) {
$content = str_replace(['rank-math-link', 'class=""'], '', $content);
}
return $content;
}
add_filter('the_content', 'filter_the_content_remove_rank_math_link', 1);
}
Yes, you can also change the str_replace
or used a regex