Menu

php syntax highlighting

2005-09-01
2013-04-26
  • Fausto Piovesan

    Fausto Piovesan - 2005-09-01

    It would be nice to have php syntax highlighting. Now I`m using     language = CPP to my php files.

    I don't know if it is dificult since a php document can have php blocks (with c like comments) and (x)html blocks (with html comments). One solution would be to ignore the html blocks (do not allow folders here).

     
    • Marc Kerbiquet

      Marc Kerbiquet - 2005-09-04

      Adding php syntax highlighting should not be too difficult. It requires some refactoring to allow mixing html syntax highlighting with another language but it is feasible.

      The issue arises from the folding markers. The load and save functions are not aware of the syntax, so only html blocks or php blocks could be folded.

      It is not possible to disable the folding operations when the caret is in an html block because the language of a line can change (after a cut and paste, after inserting a <? or a ?>, ...).

      I can see only two options:
      1. Make the load and save functions aware of the syntax for each line of the file.
      2. Save folding markers using php comments only and the user has to take care what to fold.

      Making load and save functions aware of the syntax is more difficult. But the most important issue is that a bug with parsing would save a corrupted file (with syntax highlighting, a bug just causes bad colors).

      You are the first to ask for php in code-browser, so I don't know if users are interested to write php with cb and if they would accept to fold only the code part. But I would be happy to add php syntax highlighting or other dual syntax languages such as jsp.

       
    • AdamG

      AdamG - 2006-07-03

      I would be interested as well :-) I am looking for general tool for code browsing and this look ok but php is missing, I have to try to use CPP to see if it is good enough.

      Thanks for great tool anyway :-)

       
    • Marc Kerbiquet

      Marc Kerbiquet - 2006-07-06

      I've just added it. It wasn't difficult since I've already refactored the syntax highlighting code for JSPs in the previous version.

      I have to do some tests before releasing a new version because I've also redesigned the syntax highlighting to fix issues with python docstrings. But I'll release it soon.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.