Community
    • Login

    php(+html) highlighting issue

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 2.9k Views 2 Watching
    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.
    • jahsqlJ Offline
      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 FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors