SpellChecker

Summary: How to enable spell-cheking on a wiki
Version:
Prerequisites:
Status: Unmaintained
Maintainer:
Categories: Editing, GUI, Obsolete

This recipe is no longer maintained, and the latest version appears to no longer work. As of 2024 all major browsers do have built-in spell-checkers for most languages and wiki editors may be better off enabling these instead of a custom recipe.

Note: The current pub/speller/spellchecker.php file has a XSS vulnerability, reported by Aaron Costello. He suggests the following fix/changes applied to the print_textinputs_var() function in /pub/speller/spellchecker.php:

function print_textinputs_var() {
  global $textinputs;
  foreach( $textinputs as $key=>$val ) {
    # $val = str_replace( "'", "%27", $val );

    $escaped_val = htmlspecialchars(urldecode($val));
    echo "textinputs[$key] = $escaped_val;\n";
  }
}

Question

How can I enable spell checking of my wiki-text?

Answers

There are a number of possible solutions to this, but many of them are limited by the lack of good spell checking programs in PHP. If the javascript solution outlined below does not work for you because you can't install the components, you may at least try a user (browser) base spell checking solution.

1. Javascript interactive spellchecking with Aspell

The "Speller Pages" project when combined with GNU Aspell provides a good solution in Javascript for interactive spell checking of wiki pages. The spellchecker.zipΔ archive contains the files needed to install Speller Pages and configure it into PmWiki's editing system.

Spell checking has been enabled on this page, so you can experiment with it yourself. Simply hit "edit page", add some text, and then use the "spell check" button that appears in the graphical toolbar.

Requirements

The Spell Checker recipe requires that the PmWiki server have a copy of GNU Aspell installed and configured correctly. Aspell can be obtained from http://aspell.sourceforge.net. Aspell is reportedly available for Windows environments as well, although we have not tested this yet. After installing Aspell you must also install at least one dictionary.

Once you have Aspell installed, simply download and unpack the spellchecker.zipΔ archive. Then add the line:

    include_once("$FarmD/cookbook/spellchecker.php");

to a local customization file such as local/config.php.

NOTE: for a wikifarm you will also have to change the /cookbook/spellchecker.php file. Change the 3 variables "$PubDirUrl" to "$FarmPubDirUrl".

If you haven't already also add the line

  $EnableGUIButtons = 1;

to the customization file. In addition, you may need to set correct values for variables defined in pub/speller/spellchecker.php:

  • $aspell_prog - the path to the Aspell command
  • $aspell_opts - options used to call aspell (may want to customize language dictionary setting)
This script will only work under PmWiki 2.0.beta22 or later.

2. Use a browser add-on spellchecker

Firefox:

  • Firefox 2 has a built-in spell checker
  • Firefox 1:

Install the SpellBound extension for Firefox http://spellbound.sourceforge.net/
Supported languages: more than 50

note: I've not managed to get it running on Trunk builds or Deer Park builds just yet.
Question: Is Firefox 1.5 support planned? When will be available? Thanks! -- Gabe

Install the Google Toolbar extension for Firefox, found at http://toolbar.google.com/; supports Firefox 1.0+ and 1.5.

Opera:

Add Aspell spellchecking to Opera: http://www.opera.com/support/tutorials/opera/spellcheck/
Supported languages: more than 20

Internet Explorer:

Try add-on ieSpell http://www.iespell.com/
Supported languages: English (American, British and Canadian)
Freeware

Also, the Google toolbar includes a spellchecker.
(http://toolbar.google.com)

Safari:

Supported by default. Right-click in text box and select Spelling -> Check Spelling as You Type.

Comments

  • It would be helpful to have the Aspell language choice parameter in the local/config.php or at least in cookbook/spellchecker.php Isidor
    Unfortunately, the script that does the spell checking itself (pub/speller/spellchecker.php) runs entirely independently of PmWiki and PmWiki's configuration scripts. Thus there doesn't seem to be a good way to place the language setting into a PmWiki configuration file and have it be read by the spell checking script. --Pm
  • Has anybody been able to get it to work in Windows? I installed ASpell correctly, but the spelling window comes up and it contains no text (either being checked or suggestions). Any ideas?
    JavaJunky I never got around to testing my script in Windows, but one thing I do know is the current script doesn't work in a WikiFarm (you see the behavior you're describing). Its a simple fix that I just haven't submitted yet. Are you running it in a Farm?
    Noel Llopis Actually, no I'm not running it in a farm (although I'm about to switch to it). What's involved in making it work with a farm? I might want to look at it if you don't have the time.
    I got it to work in Win2K. I have installed Aspell 5.033 and the English dictionary. I have found that I have to change the hard code $aspell_prog = '/usr/local/bin/aspell' (in the spellchecker.php) to my actual Aspell install $aspell_prog = '"D:/Program Files/Aspell/bin/aspell.exe"'. Very useful script. Thanks.
    I tried setting $aspell_prog = 'c:/progra~1/aspell/bin/aspell.exe'; but it still won't work for me. The spelling dialog box comes up empty without any words in it. Is there a way to get some feedback on what's going wrong? Like a std error channel or something?
    GaryV I also couldn't get it to work under windows. I tried setting $aspell_prog = 'c:\progra~1\aspell\bin\aspell.exe' and $tempfiledir = "." (since ./ is invalid in Windows). When the spellcheck window appears, you cal view the source for that window and see the apparent error, which I've uploaded Attach:Attach:SpellCheckWindow.txt Δ. If I execute the equivalent command from the command prompt or a batch file, aspell runs as expected.
    To get it working in windows you have to add the full actual path to the aspell exe file in the spellchecker.php line $aspell_prog =' path to aspell ', for example
    "C:/Program Files/Aspell/bin/aspell.exe"
    make sure to include the "quotes" inside the single quotes and to change the '\' to '/' This made it work for me. -Tud
  • I couldn't get aspell installed on my server, so as a work-around I have encouraged my users to use Firefox with the spellbound extension: http://spellbound.sourceforge.net/ - this has worked great so far! Jason Counsel
    I can thoroughly recommend the spellbound plugin, I use it myself :) WRT to installing aspell, if someone could find the time to write a spell checking engine in php [it can't be that hard, really ;)....I've just got no time spare at the minute] it should be a trivial matter of integrating a fallback spell-checker into the script so it reverts to using the php-only variant when aspell cannot be located? JavaJunky
  • I threw together a pspell replacement (I named it pspellX). This should work on most PHP installs without modification to the PHP config. It doesn't have the dictionary file bundled with it - the dictionary file can be found here:

    http://sourceforge.net/projects/jazzy

    Here is the source for the spell checker Attach:pspellX.phpΔ -- Have fun! Wendell Brown

Contributors

  • JavaJunky, 2005-02-18
  • Pm, 2005-02-25, redesign installation scripts

Sandbox

Try spell-checking this page here.

this is na incorect senteeence