I am using the following script to remove the diacritics from text, and I was wondering if there is a way to color the diacritics in html or PHP instead of removing them (the example is in Arabic, but the same applies to Hebrew, French, even English.. etc.).
Javascript code:
$(document).ready(function(){
var bodyText = $('#page_content').html();
function replaceChars()
{
newBodyText = bodyText.replace(/َ/gi,'');
newBodytext = newBodyText.replace(/ً/gi,'');
newBodyText = newBodyText.replace(/ُ/gi,'');
newBodyText = newBodyText.replace(/ٌ/gi,'');
newBodyText = newBodyText.replace(/`/gi,'');
newBodyText = newBodyText.replace(/ِ/gi,'');
newBodyText = newBodyText.replace(/ٍ/gi,'');
newBodyText = newBodyText.replace(/،/gi,'');
newBodyText = newBodyText.replace(/ْ/gi,'');
newBodyText = newBodyText.replace(/ّ/gi,'');
}
$('.testMe').toggle(function() {
replaceChars();
$('#page_content').html(newBodyText);
$('#actionDiacritics').html('Show');
}, function() {
$('#page_content').html(bodyText);
$('#actionDiacritics').html('Hide');
});
});
Running demo: http://jsfiddle.net/8jAL8/29/
Input: لاَ تَتَعَجَّبُواٌ مِنْ هذَا:
Example of the needed output:
There is an option to do that in Microsoft Word, or LibreOffice, and also I found something here but the first answer needs a fixed text to work, and the second answer just colorizes the whole upper part of the text.