[2] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN"> |
---|
| 2 | <html> |
---|
| 3 | <head> |
---|
| 4 | <title>HTMLArea Spell Checker</title> |
---|
| 5 | </head> |
---|
| 6 | |
---|
| 7 | <body> |
---|
| 8 | <h1>HTMLArea Spell Checker</h1> |
---|
| 9 | |
---|
| 10 | <p>The HTMLArea Spell Checker subsystem consists of the following |
---|
| 11 | files:</p> |
---|
| 12 | |
---|
| 13 | <ul> |
---|
| 14 | |
---|
| 15 | <li>spell-checker.js — the spell checker plugin interface for |
---|
| 16 | HTMLArea</li> |
---|
| 17 | |
---|
| 18 | <li>spell-checker-ui.html — the HTML code for the user |
---|
| 19 | interface</li> |
---|
| 20 | |
---|
| 21 | <li>spell-checker-ui.js — functionality of the user |
---|
| 22 | interface</li> |
---|
| 23 | |
---|
| 24 | <li>spell-checker-logic.cgi — Perl CGI script that checks a text |
---|
| 25 | given through POST for spelling errors</li> |
---|
| 26 | |
---|
| 27 | <li>spell-checker-style.css — style for mispelled words</li> |
---|
| 28 | |
---|
| 29 | <li>lang/en.js — main language file (English).</li> |
---|
| 30 | |
---|
| 31 | </ul> |
---|
| 32 | |
---|
| 33 | <h2>Process overview</h2> |
---|
| 34 | |
---|
| 35 | <p> |
---|
| 36 | When an end-user clicks the "spell-check" button in the HTMLArea |
---|
| 37 | editor, a new window is opened with the URL of "spell-check-ui.html". |
---|
| 38 | This window initializes itself with the text found in the editor (uses |
---|
| 39 | <tt>window.opener.SpellChecker.editor</tt> global variable) and it |
---|
| 40 | submits the text to the server-side script "spell-check-logic.cgi". |
---|
| 41 | The target of the FORM is an inline frame which is used both to |
---|
| 42 | display the text and correcting. |
---|
| 43 | </p> |
---|
| 44 | |
---|
| 45 | <p> |
---|
| 46 | Further, spell-check-logic.cgi calls Aspell for each portion of plain |
---|
| 47 | text found in the given HTML. It rebuilds an HTML file that contains |
---|
| 48 | clear marks of which words are incorrect, along with suggestions for |
---|
| 49 | each of them. This file is then loaded in the inline frame. Upon |
---|
| 50 | loading, a JavaScript function from "spell-check-ui.js" is called. |
---|
| 51 | This function will retrieve all mispelled words from the HTML of the |
---|
| 52 | iframe and will setup the user interface so that it allows correction. |
---|
| 53 | </p> |
---|
| 54 | |
---|
| 55 | <h2>The server-side script (spell-check-logic.cgi)</h2> |
---|
| 56 | |
---|
| 57 | <p> |
---|
| 58 | <strong>Unicode safety</strong> — the program <em>is</em> |
---|
| 59 | Unicode safe. HTML entities are expanded into their corresponding |
---|
| 60 | Unicode characters. These characters will be matched as part of the |
---|
| 61 | word passed to Aspell. All texts passed to Aspell are in Unicode |
---|
| 62 | (when appropriate). <strike>However, Aspell seems to not support Unicode |
---|
| 63 | yet (<a |
---|
| 64 | href="http://mail.gnu.org/archive/html/aspell-user/2000-11/msg00007.html">thread concerning Aspell and Unicode</a>). |
---|
| 65 | This mean that words containing Unicode |
---|
| 66 | characters that are not in 0..255 are likely to be reported as "mispelled" by Aspell.</strike> |
---|
| 67 | </p> |
---|
| 68 | |
---|
| 69 | <p> |
---|
| 70 | <strong style="font-variant: small-caps; color: |
---|
| 71 | red;">Update:</strong> though I've never seen it mentioned |
---|
| 72 | anywhere, it looks that Aspell <em>does</em>, in fact, speak |
---|
| 73 | Unicode. Or else, maybe <code>Text::Aspell</code> does |
---|
| 74 | transparent conversion; anyway, this new version of our |
---|
| 75 | SpellChecker plugin is, as tests show so far, fully |
---|
| 76 | Unicode-safe... well, probably the <em>only</em> freeware |
---|
| 77 | Web-based spell-checker which happens to have Unicode support. |
---|
| 78 | </p> |
---|
| 79 | |
---|
| 80 | <p> |
---|
| 81 | The Perl Unicode manual (man perluniintro) states: |
---|
| 82 | </p> |
---|
| 83 | |
---|
| 84 | <blockquote> |
---|
| 85 | <em> |
---|
| 86 | Starting from Perl 5.6.0, Perl has had the capacity to handle Unicode |
---|
| 87 | natively. Perl 5.8.0, however, is the first recommended release for |
---|
| 88 | serious Unicode work. The maintenance release 5.6.1 fixed many of the |
---|
| 89 | problems of the initial Unicode implementation, but for example regular |
---|
| 90 | expressions still do not work with Unicode in 5.6.1. |
---|
| 91 | </em> |
---|
| 92 | </blockquote> |
---|
| 93 | |
---|
| 94 | <p>In other words, do <em>not</em> assume that this script is |
---|
| 95 | Unicode-safe on Perl interpreters older than 5.8.0.</p> |
---|
| 96 | |
---|
| 97 | <p>The following Perl modules are required:</p> |
---|
| 98 | |
---|
| 99 | <ul> |
---|
| 100 | <li><a href="http://search.cpan.org/search?query=Text%3A%3AAspell&mode=all" target="_blank">Text::Aspell</a></li> |
---|
| 101 | <li><a href="http://search.cpan.org/search?query=XML%3A%3ADOM&mode=all" target="_blank">XML::DOM</a></li> |
---|
| 102 | <li><a href="http://search.cpan.org/search?query=CGI&mode=all" target="_blank">CGI</a></li> |
---|
| 103 | </ul> |
---|
| 104 | |
---|
| 105 | <p>Of these, only Text::Aspell might need to be installed manually. The |
---|
| 106 | others are likely to be available by default in most Perl distributions.</p> |
---|
| 107 | |
---|
| 108 | <hr /> |
---|
| 109 | <address><a href="http://dynarch.com/mishoo/">Mihai Bazon</a></address> |
---|
| 110 | <!-- Created: Thu Jul 17 13:22:27 EEST 2003 --> |
---|
| 111 | <!-- hhmts start --> Last modified: Fri Jan 30 19:14:11 EET 2004 <!-- hhmts end --> |
---|
| 112 | <!-- doc-lang: English --> |
---|
| 113 | </body> |
---|
| 114 | </html> |
---|