HTML tag highlighting not working for tags with embedded PHP code

HTML tag highlighting not working for tags with embedded PHP code

3

    Mar 15, 2011#1

    I have added tpl extension to html.uew, but it does not match div tags. What I am doing wrong?

    6,606548
    Grand MasterGrand Master
    6,606548

      Mar 15, 2011#2

      The match brace feature has not changed in UltraEdit v17.00. Therefore the command Search - Match Brace works as before. Bulgrien and I have already sent late on beta test period (it was already release candidate period) feature enhancement suggestions for UE v17.10 for a Match Tag command executed from menu, toolbar, keyboard or mouse.

      UltraEdit v17.00 introduces the feature XML/HTML tag highlighting which can be enabled or disabled at Advanced - Configuration - Editor Display - Advanced.

      By the way: To which html.uew do you have added the file extension TPL? To html.uew in the directory displayed in Advanced - Configuration - Editor Display - Syntax Highlighting or to html.uew in the wordfiles subdirectory of the UltraEdit program files directory?

      The wordfiles directory in the UltraEdit program files directory is updated only by the installer and is by default write-protected on Windows Vista, Windows 7 (for all accounts) and on Windows 2K/XP with a restricted user account. UltraEdit itself copies those wordfiles to the wordfiles directory in the application data directory with user confirmation after an upgrade or silent on new installation respectively first usage by a user on a machine with multiple user accounts.

      3

        Mar 15, 2011#3

        To add .tpl I followed the guide and in Syntax Highlighting selected HTML and clicked open.

        The .tpl files highlight ok, just no tag matching.

        I have uploaded a screenshot in case that helps.

        Thanks for your time.
        Capture.PNG (45.06KiB)

        6,606548
        Grand MasterGrand Master
        6,606548

          Mar 16, 2011#4

          The code folding engine totally fails on your TPL file with all the inline PHP elements as you can see on the completely wrong placed [-] symbols. Therefore the HTML tag highlighting fails too. It is necessary that the code folding engine finds the matching opening and closing tags correct to get the tags highlighted. For your TPL file this does not work and I think you can't do anything to correct this. It would be interesting what is indicated in the status bar at bottom of the UltraEdit window when you scroll the cursor horizontally in the active line (<form ...>). The fourth box should indicate HTML, PHP, HTML, PHP, ... It looks like if the language changes within a tag from HTML to PHP the code folding engine and the XML/HTML tag highlighting fail. In XML it is not allowed to have inside a tag another tag and in HTML this is also not possible in most cases, an exception is your code.

          3

            Mar 17, 2011#5

            I have checked this, seems that it stays as HTML unless I click inside a PHP tag, then it changes to PHP.

            Does that help?
            Capture.PNG (74.11KiB)

            6,606548
            Grand MasterGrand Master
            6,606548

              Mar 18, 2011#6

              Okay, the syntax highlighting feature has no problems with the PHP code inside the HTML tags.

              But as I already wrote, it looks like the code folding and the XML/HTML tag highlighting feature does not support tags inside tags, in other words < and > inside a tag starting with < and ending with >. That makes tags parsing very difficult, not just for the editor and is very unusual and typically not allowed, although permissible in your case.

              Most PHP writers use simply 1 echo command to output the entire HTML line with the variable elements instead of starting the form with HTML, switchting to PHP for the id string, continue with HTML, switch again to PHP for the action string and finish the tag with HTML. That is a nightmare for all programs which need to interpret such code including the PHP interpreter. Also some lines above where opening < is HTML, followed by tag name and perhaps also attributes from PHP, closing > is again HTML, displayed content again from PHP, </ again HTML, closing tag name from PHP, and finally > from HTML is very uncommon. It is not wrong, but good PHP coding looks different. The entire snippet you captured to a screenshot should be inside a complete, single PHP block.

              However, you can report this by email to IDM support and ask for an enhancement.

              But to be honest, if I - a user of UltraEdit (and a developer), not an employee of IDM - would be asked to enhance code folding and XML/HTML tag highlighting to support tags inside tags, I would not do that. Why? Tags inside tags are only possible in HTML, not in XML. I think, it is very uncommon that tags to embed code with a different language are used inside HTML tags, but I may be wrong with my statement. But the main reason to deny such an enhancement request would be that parsing tags would become very complicated and complicated means always slow and causes often many mistakes (false-positive). Parsing for open tags with the Perl regular expressions <.+> (single line tag) or <[^>]+> (multi line tag) and for close tags with </.+> or </[^>]+> is very fast, but taking tags inside tags into account would dramatically slow down the parsing for tags.