Syntax Highlighting and GeSHi lazarus / 8-Other ---------------------------------------------------------------------- idog · 2010-07-20 23:45 Hello all, I've recently learned of GeSHi (http://qbnz.com/highlighter), a very cool open-source project in PHP for generic syntax highlighting of code in web pages. While it contains both "Pascal" and "Delphi" syntax files, I found them incomplete and started to contemplate creating a new syntax file for FreePascal - and this is where I need your help in two matters: 1. Do you know of anyone who did this already, or something similar, so I won't do redundant work? 2. I believe the smartest thing to do is to base the syntax file as far as possible on the same definitions as Lazarus's own Syntax Highlighter - so where do I find these definitions? Are there specific files in the Lazarus/FPC installation that contain the FreePascal keywords, symbols etc.? Thanks in advance, Ido ---------------------------------------------------------------------- Martin_fr · 2010-07-20 23:54 I don't know about the web stuff, nor if others did already du anything. About: Quote from: idog on July 21, 2010, 01:45:07 am 2. I believe the smartest thing to do is to base the syntax file as far as possible on the same definitions as Lazarus's own Syntax Highlighter - so where do I find these definitions? Are there specific files in the Lazarus/FPC installation that contain the FreePascal keywords, symbols etc.? components/synedit/SynHighlighterPas.pp The SynEdit highlighters are hardcoded, so the keywords are all in the code. ---------------------------------------------------------------------- idog · 2010-07-21 00:56 Quote from: Martin_fr on July 21, 2010, 01:54:12 amcomponents/synedit/SynHighlighterPas.pp The SynEdit highlighters are hardcoded, so the keywords are all in the code. Great, thanks. that's for the keywords, and the symbols won't be too hard to define manually. Now to a related question: Is there a list of, or alternatively, where is the system unit with all the standard functions such as WriteLn, ReadLn, Ord, Chr etc. in human-readable format? While not strictly syntax, highlighting these common names can still be useful. BTW in anyone wants to see GeSHi in action, you can look at the longer code segments on this page from my website (in Hebrew), that shows how to write a Tic-Tac-Toe playing program :-) http://www.idogendel.com/programming/projects/tictactoe.php I just give the GeSHi object raw ASCII code, and it plants a highlighted version into the HTML. ---------------------------------------------------------------------- Zaher · 2010-07-21 19:47 To understand you, you need a pascal utils, pass to it a code string and return it in colored HTML like as GeSHi? ---------------------------------------------------------------------- idog · 2010-07-21 22:39 Quote from: Zaher on July 21, 2010, 09:47:28 pmTo understand you, you need a pascal utils, pass to it a code string and return it in colored HTML like as GeSHi? No, it's the other way around...  I need an updated GeSHi format file for the Object Pascal language. If people want to show highlighted Object Pascal code in their blog or website, they will only need GeSHi and this file. Basically, I just need a list of all the keywords and symbols in Object Pascal - and I thought a list of the system functions will also be nice. I discussed this with the person behind GeSHi. He seems to think it's best not to create a new file but rather to update the existing "Delphi" file... what do you folks think? ---------------------------------------------------------------------- Martin_fr · 2010-07-21 23:44 Take a look at the docs? http://www.freepascal.org/docs- html/ref/ref.html All the keywords and what else is there... however, if it comes for example to hind-directives, the word must only be highlighted in certain places. var   deprecated: Integer deprecated; The 2nd occurrence of deprecated would be nice to be highlighted. (no need to check, it's a bug in the IDE too) ---------------------------------------------------------------------- idog · 2010-07-22 00:26 Quote from: Martin_fr on July 22, 2010, 01:44:57 amTake a look at the docs? http://www.freepascal.org/docs-html/ref/ref.html Thanks! very useful for lots of things - still, it doesn't list the common routines such as Chr/Ord/WriteLn... Quote from: Martin_fr on July 22, 2010, 01:44:57 amhowever, if it comes for example to hind-directives, the word must only be highlighted in certain places. var   deprecated: Integer deprecated; The 2nd occurrence of deprecated would be nice to be highlighted. (no need to check, it's a bug in the IDE too) I'm not sure GeSHi's generic parser is up for this kind of complexity. Certainly not in the stable version - maybe the engine gets better in the new development versions. I'll have to check on that - after I negotiate separate files for Delphi and for FPC Object Pascal :-) ---------------------------------------------------------------------- Zaher · 2010-07-22 11:45 I use my own PHP code highlighter, it faster than GeSHi, http://www.parmaja.com/forums/viewtopic.php?id=45&action=new It based on SynEdit idea to parse the code, GeSHi use RegEx, i like to work on it again because my site very old. ---------------------------------------------------------------------- idog · 2010-07-23 08:34 Quote from: Zaher on July 22, 2010, 01:45:49 pmI use my own PHP code highlighter, it faster than GeSHi, http://www.parmaja.com/forums/viewtopic.php?id=45&action=new It based on SynEdit idea to parse the code, GeSHi use RegEx, i like to work on it again because my site very old. Very nice! But can it highlight symbols as well (+, =, ^ ...)? I don't see this in the posts in the parmaja  forum. ---------------------------------------------------------------------- Zaher · 2010-07-23 12:38 Symbols not supported, I added to my TODO