From 21777a2bc74163743daaa35c93a1364e269d46c7 Mon Sep 17 00:00:00 2001 From: matthiasgrimm Date: Mon, 13 Jun 2005 23:58:34 +0200 Subject: spellchecker should not check links The spellchecker should not check links because this are mostly no real words. This patch installs some filters so that links won't be transfered to the spellchecker. darcs-hash:20050613215834-7ef76-444b4aa6ca9f471ae99c3f6fd3e3b9d380161f8a.gz --- lib/exe/spellcheck.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/exe') diff --git a/lib/exe/spellcheck.php b/lib/exe/spellcheck.php index d9086f9c6..7147673b7 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 + */ +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)){ -- cgit v1.2.3