Extending the HTML Editor [message #676047] |
Thu, 02 June 2011 11:50  |
Eclipse User |
|
|
|
Hi,
sorry for crossposting, but i thought i'd create a separate subject instead of hijacking an existing thread.
i'm trying to extend the html editor to provide syntax highlighting for a templating language which looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>My Webpage</title>
</head>
<body>
<ul id="navigation">
{% for item in navigation %}
<li><a href="{{ item.href }}">{{ item.caption }}</a></li>
{% endfor %}
</ul>
<h1>My Webpage</h1>
{{ a_variable }}
</body>
</html>
What i've found out so far is for that to work i need to do the following:
1. Declare a org.eclipse.wst.sse.core.modelHandler
2. In that ModelHandler, implement "getDocumentLoader()" and return a custom DocumentLoader, which extends "HTMLDocumentLoader".
3. In the DocumentLoader, override "getParser()" and return a custom RegionParser (which in turn extends XMLSourceParser)
4. The SourceParser overrides the "getTokenizer()" method.
I assume that the Tokenizer is responsible for detecting the Tokens in the InputString - which are the tokens of the custom templating languages grammar.
This is where i'm stuck. The Tokenizer which is returned by the XMLSourceParser is a XMLTokenizer. From what i could find out, the source code
of the XMLTokenizer has been generated by jflex - from a file like
org.eclipse.wst.sse.core/DevTimeSupport/SedModel/HTMLTokenizer/devel/XMLTokenizer.jflex
My question now is: To add syntax-highlighting for a templating engine which adds non-xml structures to the document, do i need to specify such a .jflex
grammar and generate the corresponding tokenizer from this "jflex" library?
Is there probably a simpler solution for this problem? I've found the org.eclipse.wst.sse.ui.semanticHighlighting extension point, but i think this works only for language constructs already known by WTP.
thanks!
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.18280 seconds