Description
MTSpeling is a Movable Type plugin by Alexei Kosut to add spell-checking capabilities to a Movable Type weblog. It adds a global filter that allows any template tag output to be spell-checked, and provides tags for fully-customizable suggestion output.
Download
Current version: 0.2
Installing MTSpeling
Requirements
- Movable Type. I have only tested with version 2.51, although others may work.
- International Ispell 3.1 or later.
- Lingua::Ispell.
This is a Perl module to access Ispell from Perl. It must be installed
in your site’s Perl installation or the Movable Type
extlib
directory.
Installation
- Copy
MTSpeling.pl
into your Movable Typeplugins
directory. - Edit
MTSpeling.pl
if necessary with your configuration information. You will need to know the full path location of theispell
binary on your system.
Documentation
Global tag attribute: check_spelling
Add the check_spelling attribute to any Movable Type
template tag to check its spelling. Pass a value of
“1” to make red any term not in the dictionary (by adding
an HTML font
tag). For example, to display the
body of an entry with misspelled words in red, you might use:
<$MTEntryBody check_spelling=”1”$>
Use an attribute value of “2” to wrap misspelled words
with a <span class="spellingerror">
tag, which
allows you to customize the display with a style sheet. To check
spelling, but leave the tag’s output unmodified use a value of
“0”.
Each tag that is spell-checked will add to the results available
using the <MTSpellingResults>
tag. Following
</MTSpellingResults>
, the results will be cleared
for future uses.
Spelling Suggestion Tags
The following tags are available for use in displaying the results of
spelling suggestions (see the Movable Type manual for information on
the use of template tags). These results will include misspelled words from
each prior use of the check_spelling
attribute.
- MTSpellingIfErrors
A container tag: the contents of this container will be displayed if there has been at least one spelling error. This allows the spelling results to be displayed only if there has been a misspelling. - MTSpellingResults
A container tag representing a list of spelling results, one for each misspelled word in previous uses of thecheck_spelling
attribute. Each of the following tags are used to display a particular piece of information about a suggestion. - MTSpellingResultTerm
The term that was misspelled. - MTSpellingResultIfSuggestions
A container tag: the contents of this container will be displayed if the plugin has suggestions for the current misspelled term. If the word was not in the dictionary, but suggestions are not available, the contents will not be displayed. - MTSpellingResultUnlessSuggestions
A container tag: the contents of this container will be displayed if the plugin has no suggestions for the current misspelled term. If the word was not in the dictionary, but suggestions are not available, the contents will be displayed. - MTSpellingResultSuggestions
A container tag representing a list of suggestions for the current term. - MTSpellingSuggestion
Used inside a<MTSpellingResultSuggestions>
container, represents a suggestion for the current term.
Example
The following template HTML code will display a comment preview with misspelled words displayed in red, followed by suggestions:
<$MTCommentPreviewBody check_spelling="1"$>
<MTSpellingIfErrors>
<h4>Spelling Suggestions</h4>
<table>
<MTSpellingResults>
<tr><th align="left"><$MTSpellingResultTerm$></th>
<td><MTSpellingResultIfSuggestions>
<MTSpellingResultSuggestions>
<$MTSpellingSuggestion$>
</MTSpellingResultSuggestions>
</MTSpellingResultIfSuggestions>
<MTSpellingResultUnlessSuggestions>
<em>No suggestions</em>
</MTSpellingResultUnlessSuggestions></td>
</tr>
</MTSpellingResults>
</table>
</MTSpellingIfErrors>
You might use code similar to this in the comment preview template to provide spell-checking for comments.
Spell-checking Weblog Entries
You can add spell-checking to comment previews by modifying the comment preview template, as shown above. However, since Movable Type does not provide access to the templates use to generate the content management system, adding spell-checking to the entry preview requires modifying the Movable Type software, as follows:
- Locate
CMS.pm
in thelib/MT/App
subdirectory of your Movable Type installation. - Find the
preview_entry
subroutine, and the location where the$preview_code
variable is set. This will be line 2034 in Movable Type 2.51. - Replace the
$preview_code
initialization (the lines beforeHTML
) with your new HTML, including any template tags to display spell-checking information. - (Optional) You may wish to make use of the
<$MTInclude$> tag, to place your spell-checking code
in a module that can be included from several places. To make the
<$MTInclude$>
tag work, you will first need to add the following line of Perl code above the$preview_code
initialization:$ctx->stash('blog_id', $blog_id);
Don’t forget to make a backup copy of your Movable Type software before making changes, as modifications could make your weblog inaccessible!
Using a personal dictionary
MTSpeling provides support for a personal dictionary of words that
it will treat as spelled correctly, stored as a cookie on the user’s
web browser. The only support in the plugin is to be able to read and
parse the spelling-dict
cookie as a colon-seperated list
of words. If you want to make use of this, you’ll have to write your
own code to create and add to this cookie. In my weblog, I use
JavaScript to provide an ‛add to dict“ link in the list of
spelling suggestions that adds a word to this cookie. You could also
write a server-side script to do something similar.
There is no current support in the plugin for dictionaries stored anywhere other than as a cookie in the browser.
Version History
0.2
- Initial release
Known Bugs
- The name is an awful pun. Years ago, I added it to Apache, and now I introduce it to Movable Type. It will not be changed.
Contact the Author
Please send any comments or suggestions to Alexei Kosut at akosut@cs.stanford.edu
or comment below.
Related weblog entries
Comments & Trackbacks
- MTSpeling Plugin
- Re: MTSpeling (Dylan)
- Preview
- Install me post-haste
- Re: MTSpeling (david)
- Re: MTSpeling (olly)
- Re: MTSpeling (Neil)
- Re: MTSpeling (Yuan-Chung Cheng)
- Beter Speling
- Bugzilla Documentation updates
- add spell-checking in comments
- Re: MTSpeling (Aaron)
- Re: MTSpeling (Del Simmons)
- Why Yes, Those Are New Tweaks
- Re: MTSpeling (Venomous Kate)
- Spelling...
- Jabber, Spell Check, Bot, Web page
- So little time...
- So little time...
- Spell-checking
- Spell checker!
- MTSpeling in 2.64 (works fine!) (Mike)
- Blog spam
- spellnig test
- MT-Preview absolutely rocks, but....
- غلطياب املايي mt
- Re: MTSpeling (Pedro Custodio)
- غلطياب املايي MT
- Spell Check Plugin
View all comments / Post a new comment