I know there are many arguments as to why this is a bad idea, but in my implementation I\'m planning on enabling/disabling bad words in the account settings. In other words
The JSON object you return cannot have repeated attribute names. Instead of { w: 'Swear1', w: 'Swear2' }
it should be [ 'Swear1', 'Swear2' ]
.
You can parse the text to filter and wrap every occurrence of a swear word between tags with a particular class attribute and toggle them with a function. That should be a simple approach.