the code below is for adding links to words, but it work for the whole html and broke it.
I want make it effect only on child “p”
.post-body p
the code :
<script>
//<![CDATA[
function linkWords(elem,words,links) {
elem.innerHTML=elem.innerHTML.replace(
RegExp('('+words.join(')|(')+')','gi'),
function(){
for (var i=1;i<arguments.length-2;i++)
if (arguments[i])
return '<a href="'+links[i-1]+'" rel="tag">'+arguments[0]+'</a>';
}
);
}
document.addEventListener("DOMContentLoaded", linkWords(document.body,
["أكشن","Signal.MD","خارق للطبيعة","سحر"],
["https://www.example.com/search/label/%D8%A3%D9%83%D8%B4%D9%86","https://www.example.com/search/label/Signal.MD","https://www.example.com/search/label/%D8%AE%D8%A7%D8%B1%D9%82%20%D9%84%D9%84%D8%B7%D8%A8%D9%8A%D8%B9%D8%A9","https://www.example.com/search/label/%D8%B3%D8%AD%D8%B1"]
));
//]]>
</script>