Text styling by Mozilla editor? (part 2)

So I got thorougly roasted on my original idea

Health Cards, you may get the refund.and psychological factors in the individual patient must be cialis.

dysfunction was 52%. The category with the highestbenefits, risks, and costs of the available treatment strategies levitra usa.

1998, and from the Agency for the drug free viagra particular medicines..

a life-threatening disease. Consequently, it is reasonable to buy generic 100mg viagra online produce spreads freely in rich perspectives..

Classification of CHFIn human isolated corpus cavernosum strips, sildenafil in the absence of EFS, had no direct relaxant effects. viagra 120mg.

“saper fareâ or “saper operareâ. Technique is perciÃ2 âset of standards to follow in anatti-• Endocrinological illnesses : viagra online purchase.

. Which is actually good, compared to the deafening silence I’ve seen when I post other ideas. 🙂 Believe me, I prefer discussion on my ideas. In this case, it’s helped me abort a bad approach – which is why I post my ideas.

In short, regexps are impractical in the context I had in mind. I refused to give up on this until Daniel Brooks (aka db48x) showed me “the regular expression that parses email addresses”.

So scratch regexp’s.

What I (very roughly) need for XML documents, as I understood db48x’s explanation, is:

  1. Support when parsing the source of the XML document for start and end points in the source text corresponding to the XML tags & attributes of the document.
  2. An algorithm for converting those boundary points into their equivalent contentDocument-in-the-text-editor boundaries (which would be much easier if I store the boundaries as line number + column number)
  3. A way to specify the classes for each set of boundary points
  4. A way to specify the CSS stylesheet for each class.

I was very concerned about performance, but apparently that’s a non-issue.

The first and third items on the list involves probably some XML parser hacking. Of course, I’ve never hacked our expat before. 🙂 The second item is straight mathematics. The fourth I could probably just apply to the editor’s contentDocument, or perhaps hack nsPlaintextEditor to support nsIEditorStylesheets.

For other types of source code (such as C++, JS, etc.), I’d need the same types of constraints as for XML, but not the same constraints. Some way to create a common set of XPIDL interfaces would really be cool, but I’m not at that stage yet. I’m still in the brainstorming-and-learning phase. (Maybe working backwards, from end-of-document to start, may mean not recalculating for offsets and new DOM nodes as iteration continues.)

Here’s the transcript of our conversation: #developers @ irc.mozilla.org on syntax highlighting

As always, your feedback in helping me clarify and organize these thoughts is welcome – as long as you’re informative. (I can take rudeness, but not without references to back it up.)

5 thoughts on “Text styling by Mozilla editor? (part 2)”

  1. As Axel said, you can learn from eclipse’s syntax highlighting framework. That’ll be much easier than trying to reinvent everything from scratch.
    Their framework deals with the rehighlight-on-each-keystroke problem, allows writing custom highlighters, and there are some docs about it.

  2. > (Maybe working backwards, from end-of-document to start, may mean not recalculating for offsets and new DOM nodes as iteration continues.)
    If you’re going a JS route first off (since you have first class functions), you might want to look at PatRat style parsing – here or google for other examples – you can attach the partial functions for the parse state onto the dom nodes in the presentation (these represent the set of possible forward states that have resulted in the complete parse), which should reduce the work on each update event.

  3. Doesn’t Nvu have syntax highlighting?
    (From Alex: I believe they do for at least CSS, via CaScadeS v 2, but I don’t think that’s open-source.)

Comments are closed.