Skip to content
Snippets Groups Projects
Commit 1e532207 authored by andi's avatar andi
Browse files

fix for UTF-8 problem in spaceslink (spellchecker)

darcs-hash:20050628191048-9977f-7fe308bc4f13f36af78cdd67bd31acff0a2ebc7f.gz
parent 4029d111
No related branches found
No related tags found
No related merge requests found
......@@ -75,12 +75,18 @@ if(function_exists($call)){
* spelling errors again.
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
* @author Andreas Gohr <andi@splitbrain.org>
*/
function spaceslink($string, $check=""){
$string = stripslashes($string);
$check = stripslashes($check);
$result = str_pad($check,utf8_strlen($string)-2," ",STR_PAD_LEFT);
return $result." ";
$result = ' '; //opening [[
$result .= str_pad('',utf8_strlen($string),' ');
$result .= $check;
$result .= ' '; //closing ]]
return $result;
}
/**
......@@ -108,18 +114,20 @@ function spell_check() {
$data = explode("\n",$string);
// don't check links and medialinks for spelling errors
$string = preg_replace('/\{\{(.*?)(\|(.*?))?(\}\})/e','spaceslink("\\0","\\3")',$string);
$string = preg_replace('/\[\[(.*?)(\|(.*?))?(\]\])/e','spaceslink("\\0","\\3")',$string);
$string = preg_replace('/\{\{(.*?)(\|(.*?))?(\}\})/e','spaceslink("\\1","\\2")',$string);
$string = preg_replace('/\[\[(.*?)(\|(.*?))?(\]\])/e','spaceslink("\\1","\\2")',$string);
// run aspell in terse sgml mode
if(!$spell->runAspell($string,$out,$err,array('!','+html'))){
//if(!$spell->runAspell($string,$out,$err)){
print '2'; //to indicate an error
print "An error occured while trying to run the spellchecker:\n";
print $err;
return;
}
#use this to debug raw aspell output
#print "1$out"; return;
// go through the result
$lines = split("\n",$out);
$rcnt = count($lines)-1; // aspell result count
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment