Simple HTML Spell Checker for NetBeans

Something I've missed in NetBeans is a spell checker for HTML files. The one by Jan Lahoda on nbextras.org is for Java files only (although the description there says it should be easy to extend it). Mine is specifically for HTML files (although it too is very easy to extend for any document). It is based on Jazzy, the Java open source spell checker.

My first experiment with Jazzy just reused the code found here within the context of a JEditorPane in a simple Java application, rather than a file on disk (which is what that source code provides for). Here's the result. One types in something in the JEditorPane...

...one then clicks "Spell" and then one can see the mistakenly spelled words (which, apparently, includes "Norway"):

Next I created a module, again using Sandip's framework for adding actions for working with editors. Here's the result:

It is still pretty simple—works on one line instead of on the whole document, doesn't allow for the exclusion of HTML tags, doesn't let you update the dictionary, and doesn't provide functionality for replacing the mispelled words. But the start is clearly there! If someone would like my sources, to extend them and make a fully fledged spell checker for HTML files, let me know and I'll pass the sources on to you.

PS: Two further enhancements would be (1) to color every wrongly spelled word in red (or underline them), (2) to add annotation support, so that each line with wrong words gets a little annotation in the left sidebar, so that lines containing wrong words can be identified more easily.

And here's an alternative approach, using Jazzy's DocumentWordTokenizer (instead of StringWordTokenizer, which didn't let me get the whole content of the document), and hyperlinks in the JEditorPane:

Now I need to work out how to get the item under the cursor. Not sure how to do that. When the 'hand' cursor clicks a hyperlink, something specific should happen for that hyperlink. However, I'm using a StringBuilder, so while each item in the list is a separate hyperlink, it is in one long string, obtained from the StringBuilder. That's where I'm stuck—not knowing how to parse the current location of the cursor (I guess I'd parse up to the linebreak, but how do I even get started parsing in the first place). I guess the best solution is to use the Output Window and its API instead...

Comments:

IMHO such a feature (spell checking) belongs to the HTML module itself.
I think you could check it in to the NBClick sandbox in the mean time.
If it would be default in NB and would work as you mentioned that it should be, than I would be very glad to extend it for NBClick, to "exlude" from spelling the "$variables" and other Velocity constructs.

Ahmed.

Posted by Ahmed Mohombe on September 15, 2006 at 02:30 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today