Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    php(+html) highlighting issue

    Help wanted · · · – – – · · ·
    2
    2
    2447
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jahsql
      jahsql last edited by

      Highlighter is too smart and not smart enough at the same time.
      First one - because it looks for html tags inside php’s output operators (or maybe in all php code, didn’t bother with checking that out).
      Second one - because it can’t understand that only one branch of “if” is executed.
      Here is an example.

      <div>
      <div> <!-- this should be highlighted -->
      <?php
      if($x==$y) {
      echo ‘<div id=“bug1”>’; /* bugged highlight to here */
      else
      echo ‘<div id=“bug2”>’;
      echo ‘</div>’;
      }
      ?>
      </div> <!-- bugged highlight from here -->
      </div>

      At the same time folding code blocks seems to work correctly. Any suggestions/solutions?

      Claudia Frank 1 Reply Last reply Reply Quote 0
      • Claudia Frank
        Claudia Frank @jahsql last edited by

        Hello jahsql,

        I don’t quite understand what you mean by

        Second one - because it can’t understand that only one branch of “if” is executed.

        Well, I understand what you are saying but I don’t see how a lexer should
        know if parts of a code get executed or not. A lexer should tokenize
        the code and color each token in regards to the defined rules.
        That the lexer gets confused by your code doesn’t surprise me as you
        have four open but only three closing tags.
        And php/html lexer has increased complexity as the lexer needs to
        satisfy php and html code together.

        Any suggestions/solutions?

        <div>
            <div> <!-- this should be highlighted -->
                <?php
                    if($x==$y) {
                        echo ‘<div id=“bug1”>’; /* bugged highlight to here */
                        echo ‘</div>’;
                    else
                        echo ‘<div id=“bug2”>’;
                        echo ‘</div>’;
                    }
                ?>
            </div> <!-- bugged highlight from here -->
        </div>
        

        Maybe I didn’t get the point but this are my two cents worth.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors