aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authormatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-06-13 23:58:34 +0200
committermatthiasgrimm <matthiasgrimm@users.sourceforge.net>2005-06-13 23:58:34 +0200
commit21777a2bc74163743daaa35c93a1364e269d46c7 (patch)
treef7da56773ccb577acaa652e3bcf48f9cc1c2f0f2
parent58bef9895361367926408711774311e4310e007a (diff)
downloaddokuwiki-21777a2bc74163743daaa35c93a1364e269d46c7.tar.gz
dokuwiki-21777a2bc74163743daaa35c93a1364e269d46c7.zip
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
-rw-r--r--lib/exe/spellcheck.php19
1 files changed, 19 insertions, 0 deletions
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
@@ -67,6 +67,21 @@ if(function_exists($call)){
}
/**
+ * 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
*
* Runs the given Text through Aspell and prints XHTML with
@@ -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)){