Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Extremely long lines followed by HTML breaks highlighting #362

Open
andreazorzi opened this issue Jun 14, 2019 · 1 comment
Open

Extremely long lines followed by HTML breaks highlighting #362

andreazorzi opened this issue Jun 14, 2019 · 1 comment

Comments

@andreazorzi
Copy link

andreazorzi commented Jun 14, 2019

Prerequisites

Description

The syntax of some parts of php code is not highlighted correctly, specifically it highlights the html code contained in the string and not the string itself

Steps to Reproduce

  1. open a blank php file and paste the following code:
<?php

    echo '
        <td id="card'.$row2["ID"].'" data-open="card" data-cardid="'.$row2["ID"].'" class="card editable" style="width: '.(100/$row2["Tipo"]).'%; '.($i == $result2->num_rows - 1 ? "margin-bottom: 0px !important;" : "").' '.($row2["Foto"] == 1 ? '' : 'min-height: auto !important;').'">
            <table style="'.$stile_card_contenuto.' '.($row2["Foto"] == 1 ? '' : 'background-color: transparent !important;').'">
                '.($row2["Foto"] == 1 ? '
                <tr>
                    <td style="background-image: url('.$row2["UrlPhoto"].'); background-position: center center; '.$stile_card.'">

                    </td>
                </tr>
                ' : '').'

                '.($row2["Testo"] != "" ? '
                <tr>
                    <td style="'.$stile_text.' '.($row2["Foto"] == 1 ? '' : 'text-align: center !important; font-size: 22px !important;').'">
                        <span class="title" style="'.$stile_titolo_fascia.'">'.$row2["Titolo"].'</span><br>
                        '.str_replace("&nbsp;", " ", $row2["Testo"]).'
                    </td>
                </tr>
                ' : '').'

                '.($row2["Bottone"] == 1 ? '
                <tr>
                    <td style="padding: 0px; height: 31px; '.($row2["Foto"] == 1 ? 'text-align: right;' : 'text-align: center !important;').'">
                        <div style="padding: 15px; padding-left: 0px; padding-top: 10px;">
                            <a href="'.str_replace("{{keyword}}", $id_newsletter, attachUtm($riga["Utm"], $row2["UrlBottone".$url_lang], $riga["Lingua"])).'" class="inbox_button" style="'.$stile_card_bottone.' '.($row2["Foto"] == 1 ? 'text-align: right;' : 'font-size: 20px !important;').'">
                                '.$row2["TestoBottone"].'
                            </a>
                        </div>
                    </td>
                </tr>
                ' : '').'
            </table>
        </td>
    ';

?>

sorry if the code is not displayed correctly, I also upload it as an attached file along with the screenshot

  1. in the fifth line of the code the syntax highlighting of the string is incorrect

Expected behavior:
the color of the fifth line should be green because it's part of a string

Actual behavior:
the string in the fifth line highlight the html code contained in the string

Reproduces how often:
I tried several times and it happened 100% of the time

Versions

Atom : 1.38.1
Electron: 2.0.18
Chrome : 61.0.3163.100
Node : 8.9.3

Additional Information

screenshot

test.zip

@Arcanemagus Arcanemagus transferred this issue from atom/atom Jun 14, 2019
@Arcanemagus Arcanemagus changed the title Sometime in php file the syntax is not highlighted correctly Extremely long lines followed by HTML breaks highlighting Jun 14, 2019
@Arcanemagus
Copy link

Arcanemagus commented Jun 14, 2019

Here's a much smaller reproduction, tested in Atom v1.40.0-nightly1:

<?php
    echo '<td id="card'.$row2["ID"].'" data-open="card" data-cardid="'.$row2["ID"].'" class="card editable" style="width: '.(100/$row2["Tipo"]).'%; '.($i == $result2->num_rows - 1 ? "margin-bottom: 0px !important;" : "").' '.($row2["Foto"] == 1 ? '' : 'min-height: auto !important;').'">
            <table>
    ';
?>

It looks like since the first line is so long that it passes the tokenization limit before it hits the end of the string starting with 'min-height: auto it falls into some bad state where it assumes that the next line is no longer PHP code and falls back to HTML for it.

This likely won't be able to be solved until #303 is merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants