sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 586 forks source link

[HTML] Wrong red highlight of JS block in HTML #3178

Open Alexey-T opened 2 years ago

Alexey-T commented 2 years ago

What happened?

big file - copy of yahoo webpage. red hilite.

Screenshot from 2021-12-25 19-41-59

text is

<script type="text/javascript">
            window.cssUrls = ["https:\/\/s.yimg.com\/nn\/lib\/metro\/g\/myy\/grid_0.0.70.css","https:\/\/s.yimg.com\/nn\/lib\/metro\/g\/myy\/video_styles_0.0.72.css","https:\/\/s.yimg.com\/nn\/lib\/metro\/g\/myy\/font_yahoosans_0.0.45.css","https:\/\/s.yimg.com\/nn\/lib\/metro\/g\/myy\/wafertooltip_0.0.16.css","https:\/\/s.yimg.com\/nn\/lib\/metro\/g\/sda\/sda_flex_0.0.48.css","https:\/\/s.yimg.com\/nn\/lib\/metro\/g\/sda\/sda_adlite_0.0.7.css","https:\/\/s.yimg.com\/aaq\/scp\/css\/colors.6da87513272a206be83f55bbb6bef68b.css","https:\/\/s.yimg.com\/os\/yc\/css\/bundle.c60a6d54.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-applet-native-ads.PencilAd.atomic.ltr.c6d68ffae4f433d3aeaa08874f29f6fe.min.css","https:\/\/s.yimg.com\/aaq\/cprops\/colors_1.1.8.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/react-wafer-featurebar.FeaturebarNew.atomic.ltr.0893ef61a53869d909868affb749d7cd.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-ntk.NTKGrid.atomic.ltr.cbf7af8d898b2721ec5038cc72de7944.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-ntk.custom_grid.desktop.c8c031e7c3525052f5b3a23b4d83feb7.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-stream.StreamGrid.atomic.ltr.9b2663e8356b9b2cac4730b522356374.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-stream.custom.desktop.bd9b346690b26f180cd5ccb2ce264a7d.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-stream.custom_grid.desktop.8c06959fb401c3abf5cb6fad61a9ff89.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-trending.Trending.atomic.ltr.ee145618a2f2fc17a75d1fcbc9f4afdc.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/react-wafer-weather.WeatherPreview.atomic.ltr.4f296566e10aa40e65a5e41b7b594072.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/react-wafer-weather.common.desktop.f392cf841749df13f60b2a28b35132dc.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-header.ybar.desktop.a5ef55315256ad2c3ff918a06f48f42e.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-stream.StreamRelated.atomic.ltr.20daca47510340e80e222f8aa68ed372.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/react-wafer-subscription.SubscriptionReminder.atomic.ltr.1fe77492b955ffe7bdabe8285b838fb0.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/react-wafer-subscription.custom.desktop.e97d6e0286bd0fe3e55a3b3f64328858.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/tdv2-wafer-user-intent.ContentPreference.atomic.ltr.d6127e972af2254646530ec34ee5d2f9.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/react-wafer-shopping.Shopping.atomic.ltr.c9f37df861b78d9d1c7c21dcc8d7a4bc.min.css","https:\/\/s.yimg.com\/aaq\/fp\/css\/react-wafer-shopping.ShoppingContent.atomic.ltr.2d2d96f4b621e41f824fe7b30a203e42.min.css","https:\/\/s.yimg.com\/aaq\/scp\/css\/viewer.5186941b658d89f9f94c1577dc7aeaf2.css"];
            window.comboCssKey = "42178de53e90061b40cee496ddeb0d85";
            window.lazyLoadCss = true;
        </script>
jfcherng commented 2 years ago

I can't reproduce it with your given text.

Alexey-T commented 2 years ago

Then take my file https www.yahoo.com.zip

and scroll to position from my picture.

jfcherng commented 2 years ago

Line 82, which contains 150k chars, is super long and ST just gives up. I don't think there is anything we can do in this repo here.

deathaxe commented 2 years ago

The closing </style> tag is located in line 80 at column 151885 and hence ignored by both syntax highlighting and the escape command, which is responsible to finalize the embedded CSS context.

As a result all the following content up to the next matching </style> tag at line 211 is parsed as CSS.

To resolve this issue at least ST's escape command would need to ignore the line length limit, to ensure an embedded syntax can be escaped from under all circumstances, even though subsequent highlighting fails.