No announcement yet.

Automatic handling of embedded language formats

  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic handling of embedded language formats

    This is a comment following on from the file format <=> session complaints from Marjolein Katsma posted with the important notice from Tim:-

    Where mixed language formats are embedded within each other, such as HTML in PHP files and HTML in ASP files, then the language interpretation / highlighting falls down. One solution was to switch fiel formats depending on what you are looking at in the file.
    I use the gvim editor a lot
    That has a very simple, but extremely powerful concept in its language files - it knows from the language syntax what language you are now 'changing' to, and will therefore switch its highlighting to that new language. Likewise the new language has constructs that know when it is terminating back to another language.
    Thus, when I look at a PHP file, the HTML parts are highlighted as per the HTML syntax, and the PHP parts as per the PHP syntax. SQL statements are highlighted using SQL syntax rules.

    Perhaps a future release could extend the file formats so that it knows the syntax for embedding other languages, and will switch to that other file format (on a stack basis), switching back when the other format reaches an 'end' syntax.

    Use of such an automatic feature will make PHP, ASP, etc far easier to compare.

  • #2

    Thanks for the suggestion. I'll make a note for formats embedded within other formats on our wish list.
    Chris K Scooter Software


    • #3
      Is javascript embedded within comments in html going to eventually show as important differences? Currently, it displays as unimportant since it is within a comment section.


      • #4
        Whether or not embedded java scirpt is supported natively in the future, you're not without options, even now.

        Option 1) For file types that you know will have embedded java, you can go into Session Settings under the Importance tab and check the importance checkbox in front of the Comment grammar element. This will make changes to comments important (whether or not they contain java code).

        Option 2) You can create one or more regular expression grammar rules that detect java code within comments then move those grammar elements above the Comment grammar element in the importance list. This way, BC3 would only consider changes to comments as important if they contain detected java code. While option 2 will certainly be more difficult to implement, theoretically it is doable.
        BC v4.0.7 build 19761