Wikimedia Developer Support

Javascript safe wikitext replace library

Hi, I want to know if there is any library/predefined function for the safe replacement of wikitext.

we know MediaWiki has markups that should not replace by bot like text inside [[File:Text.jpg]], <source>, <math>, and wikilinks, etc.