I had an idea to create a Delphi IDE add-in that would use existing IDE highlighters (hint:
IOTAHighlighter interface declared in
ToolsAPI unit) to convert source code currently open in the editor (or perhaps just selected lines) into an HTML page with highlighted syntax. The style/color codes could be read from the registry, thus respecting your current IDE settings.
Today I tried to do it but I failed miserably 😉
It turns out that the IDE doesn’t really expose its internal highlighters; you can get a reference to
IOTAHighlighter interface but don’t expect much from it. It seems to point to some generic implementation which does nothing but fill your buffer with
SyntaxOff) codes. Doh 😉
Perhaps I’m doing something wrong, but at the moment I cannot find out what that could be… In case you want to try it out and succeed where I have failed, don’t hesitate to post your results to the Delphi opentools newsgroup 😉