HTML comments do not gray out nested PHP in .php files.
Closed this issue · 2 comments
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: https://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: https://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
In php files, html comments do not gray out php that is contained within them.
Steps to Reproduce
- Create a file with .php extension.
- Fill file with the following content:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- <div>
<?php
echo 'html comments do not gray out php code within them';
?>
</div> -->
</body>
</html>
Expected behavior:
I expect the php nested within the html comment to be grayed out along with the rest of the comment.
Actual behavior:
The php nested within the html comment is syntax highlighted normally, as if it were not contained in a comment. (NOTE: The php is able to be commented out by regular php comments as expected, but it is unaffected by html comments.)
Reproduces how often:
This happens for all php nested within html comments.
Versions
Atom: 1.45.0
Electron: 4.2.7
Chrome: 69.0.3497.128
Node: 10.11.0
OS: Windows 10
Version : 1903
OS Build: 18362.778
Additional Information
This is intentional, because HTML comments do not deactivate PHP. For instance:
<!-- <?php echo 1 + 1; ?> -->
results in <!-- 2 -->
when interpreted.
If you don't like it to be colored, you can add something like this to your File -> Stylesheet...
.syntax--comment.syntax--html .syntax--php [class^="syntax--"] {
color: unset;
}
@Ingramz I see... after I posted this issue, I thought this might be the case. I think there also might be the case where php echoes a comment ending:
<!-- <div>
<?php
echo "-->";
echo "I think this is no longer in a comment after process by php";
echo "<!--";
?>
</div> -->
Thanks for your syntax highlighting fix suggestion! I think I will use it :)
I am closing this issue because the functionality is intentional.