diff --git a/lib/exe/spellcheck.php b/lib/exe/spellcheck.php index d9086f9c6e3b0962e90d7b19df0e26ff755ea0ae..7147673b700323eaa560fc9e04f304458cc0c16b 100644 --- a/lib/exe/spellcheck.php +++ b/lib/exe/spellcheck.php @@ -66,6 +66,21 @@ if(function_exists($call)){ print "The called function does not exist!"; } +/** + * replaces a link with blanks of same length + * The first string is the complete link and + * and the second optional string might be the + * alternative text that would become part of + * the result string and will be checked for + * spelling errors again. + * + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> + */ +function spaceslink($string, $check=""){ + $result = str_pad($check,utf8_strlen($string)-2," ",STR_PAD_LEFT); + return $result." "; +} + /** * Spellchecker. Called by an AJAX request * @@ -96,6 +111,10 @@ function spell_check() { /* $string = preg_replace('!<\?(code|del|file)( \+)?>!e','spellclean(\\1)',$string); */ // $string = preg_replace('!()!e','spellclean(\\1)',$string); + // don't check links and medialinks for spelling errors + $string = preg_replace('/\{\{[^\|]*\|?(.*)\}\}/e','spaceslink("\\0","\\1")',$string); + $string = preg_replace('/\[\[[^\|]*\|?(.*)\]\]/e','spaceslink("\\0","\\1")',$string); + // run aspell in terse sgml mode if(!$spell->runAspell($string,$out,$err,array('!','+html'))){ //if(!$spell->runAspell($string,$out,$err)){