how can I seprate normal text from html tags spell check it & then again place it ins
Hello
I am devloping a spell check utility using PHP4.2.2 on Redhat9, Apache & Netscape7.1. I have devloped it successfully for normal text. but problem comes when I try to check spellings in html formated text. heres how it works I have one php named compose_richtext.php. I have provided a toolbar which I got from http://www.kevinroth.com/rte/demo.htm. here user can type formated text. Their is in built feature given in that toolbar for spell check but I don't want to use that for some reasons. So I implemnted my own code. when user clicks on spell check the whole data is passed to next page i.e Spellcheck.php their I am using pspell_check & pspell_suggest for spellchecking. But the problem is how to distinguish actual text from html tags. I looked in php manual & found htmlentities nl2br htmlspecialchars but I don' think this will work for me. I can easily use strip_tags but then I will loose all the tags so how will I place the actual text again in formated form. I read something like tidy->ishtml is their but that don't works with php4.2.2 also I was unable to find proper documantation of how to use it. So can u please help me & tell me that how can I seprate normal text from html tags spell check it & then again place it inside html tags. Amit |
i dont have pspell on any php installation i have access to but you should find it simple to adapt this code
PHP Code:
|
Thanks for ur support kev.
but with this code what will happen if users text message contains < > signs for eg user text could be Arrow looks like this >-------> & the second thing which I mentioned in my Question was how will I place all the text in html format again after checking spellings because in this case we will loose all the info about previous formating. Because String $out is just plain text. Here is the code which am using Regards Amit Code:
<?php |
<edit>
Re: your edit by amit_28oct but with this code what will happen if users text message contains < > signs for eg user text could be Arrow looks like this >-------> if there not tags then you should have already converted them to < and > the second thing which I mentioned in my Question was how will I place all the text in html format again after checking spellings because in this case we will loose all the info about previous formating. Because String $out is just plain text. as i say $out is html, it is not just the plain text, run it and see. </edit> if the users message contains < > signs then how are you differentiating them from tags? The code i gave above does place stuff back into its original form with tags after youve spellchecked it so im not sure what you mean. below is what i believe to be correct code but as i dont have php compiled with the spelling libraries i cant check it. if it doesnt work i'll need to see the output. PHP Code:
|
hello kave
hear are 2 sample outputs for different values of stp stp="<span style=\"font-weight: bold;\">say</span>"; style="font-weight: bold;">say stp="<b>say sayy say</b>"; say sayy say Try yahoo's spell check function in Netscape & then try yahoo's facility of typing formated text (In IE) if possible. observe how spell checking works in boths cases that is what I am trying to do. Amit |
well one of us is doing something very wrong cos when i run your examples through my code it comes out fine
check out http://khn.homelinux.net/kev/spell.php?stp=<span style=\"font-weight: bold;\">say</span> it is definatly spellchecking the right stuff, and not the others. |
All times are GMT -5. The time now is 01:09 AM. |