Problem with HTML syntax highlighting and strings with PHP code embedded (solved)

Problem with HTML syntax highlighting and strings with PHP code embedded (solved)

2
NewbieNewbie
2

    Mar 19, 2018#1

    I am having troubles to highlight "strings" in the HTML wordfile. No matter what I try, I can't get it to treat all text inside "" quotes to be highlighted with the defined string color.
    I am using UE 24.20, I am coming from a legacy v14.xx where it worked fine, but not anymore. Has anybody this problem too?
    I have also checked with the default html.uew  included in 24.20 and same problem.

    Here is what I want it look to:
    html-good.png (1.87KiB)

    And here is what I got:
    html-bad.png (1.87KiB)

    The syntax highlighted line:

    Code: Select all

    <a class="Carrier" href="<?= $PHP_SELF ?>?c=<?= $thisCarrier ?>"><div class="Carrier"><span class="CarrierName"><?= $thisCarrier ?></span><span class="CarrierDesc">

    6,687586
    Grand MasterGrand Master
    6,687586

      Mar 20, 2018#2

      Open Advanced - Settings or Configuration - Editor display - Syntax highlighting, select language HTML if not already preselected, click on button Open and close configuration dialog with a click on button Cancel.

      The opened wordfile html.uew installed with UltraEdit v24.20 contains in first line the keyword Noquote which disables string highlighting completely. Replace this keyword by:
      1. String Chars = " EnableMLS to get only double quoted strings highlighted with the color set for color group Strings even on spanning over multiple lines while single quoted strings are not highlighted as strings.
      2. String Chars = "' EnableMLS to get double and single quoted strings highlighted with the color set for color group Strings even on spanning over multiple lines.
      3. String Chars = "' EnableMLS and add for example ' like a word to a color group like /C5"Single quoted strings" to get double quoted strings highlighted with the color set for color group Strings and single quoted strings highlighted with color set for color group Single quoted strings even on spanning over multiple lines.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Mar 20, 2018#3

        Thank you very much, that worked perfectly!

        1
        NewbieNewbie
        1

          Does highlighting affect tag recognition as well?

          Oct 04, 2018#4

          I hoped to have solved ym problem with the above post and answer which is not the case.

          My problem is that the closing </td> tag at the end of the following code line is no recognized if the cell content is as well a PHP expression:

          Code: Select all

          <td class="l150"><a href="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>?eb=<?= $Boatlist[$i]['id_b'] ?>"><?= $Boatlist[$i]['name'] ?></a></td>
          As a consequence, the entire table structure is not recorgnized and I can't collapse the table (and other subsequent elements) correctly.
          When I either replace the PHP expression in the cell content with a string it will work:

          Code: Select all

          <td><a href="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>?eb=<?= $Boatlist[$i]['id_b'] ?>">cellcontent</a></td>
          and the same is true when I have the href section of the <a> tag as static string:

          Code: Select all

          <td><a href="google.com"><?= $Boatlist[$i]['name'] ?></a></td>
          I tried to adapt the HTML.UEW settings as described, but this seems to affect only the display and not the recognition of the closing TD tag. Anything to do about it?
          td recognised.JPG (16.78KiB)
          recognised only with string in cell content
          td not recognised.JPG (18.77KiB)
          not recognised

          6,687586
          Grand MasterGrand Master
          6,687586

            Oct 04, 2018#5

            Highlighting matching tag as well as parsing for fold strings is built-in for HTML, XHTML and XML files, i.e. for files syntax highlighted with a wordfile containing the language marker HTML_LANG or XML_LANG.

            It can be seen on syntax highlighting language indication/selector in status bar at bottom of main application window on moving caret within the posted lines how UltraEdit switches between HTML, PHP, HTML, PHP, ... depending on current position of caret in active file.

            It looks like UltraEdit stops searching for a matching tag / fold string on reaching in character stream of active file a position on which syntax highlighting language changes as this means also the tag / fold string definition changes for next section in file.

            For HTML with PHP embedded anywhere it would be necessary with caret in an HTML section to strip all the PHP sections from file on searching for matching opening/closing tag as well as on searching for matching fold string. While with caret inside a PHP section the search for matching fold string should stop on end of the current PHP section.

            I suggest to send a feature request email to IDM support for this enhancement for a better tag and fold string parsing in HTML files with embedded PHP sections.
            Best regards from an UC/UE/UES for Windows user from Austria