Sunday, March 16, 2008

javascript page for code highliting

GNU source-highlight can be used for source highlighting for now.
However, it gives me an output, that is too formatted to be processed by blogger templates without problems. Also in my opinion,it is not very convenient for online purposes and can not be fast fixed (If blogger, for example will change its templates), because it is written in compiled language.

Basically, it is regexp based, regexp's applied in specified order, and give you final results.
if some code matched regexp, it is processed and removed from processing loop.

If you want to use your function for for processing sources it have to be called def_vars.

Global variables blocks and keywords have to be set inside in a way like it is done in basic.js.

I have finished with basic definition of universal language that have to be used in code,
and now highlite-processing code.

Current alfa of the javascript page placed there:http://roman.gritsulyak.googlepages.com/code-hi.html

Upper part used for downloading schema of processing, defined in javascript function.
Lower part, for processing code, input, output and presentation of how it will look like.

It also produces some shit but it can be easily filtered by hands by little snipplets.

Example of output:


fori while (a){return 0 ;}


For big code I'd better use gnu-source highlite and separate page, and for snipplets, this one gives good advice.

I have already Idea of how to fix it to work more clearly, but it requis additional effort, and I don't now, when time would be.

Idea is to 'tokenize' make array of tokens, and execute expression only once for each token, but not for all text.

Priority schema than have to be implemented and check if token satisfy highlited element.

No comments: