-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 PHP syntax highlighting not working properly #162
Comments
Hi @gpressutto5, thanks for the report! Delta uses the same language syntax definitions as bat, and bat gets them from upstream repositories (sublime syntax definitions). I think I'm seeing the behavior you're describing in bat as well as delta, do you agree? If so then this is neither a Delta bug nor a Bat bug. But beyond that, I'm not entirely sure what's going on. I see sublime syntax definitions have a header key called But doesn't it seem like that should be irrelevant if the file has the |
@dandavison It makes sense when highlighting an entire file because the code is only interpreted as PHP after the |
I am also seeing this bug. I believe this is related to sublime syntax's support for embedding languages:
The sublime syntax file appears to assume we start in A php file often contains html that embeds php. Example: https://gist.github.com/dasl-/72242668bf2dde3634802d49a23ef7b6 Other times, a php file may contain pure php and no html, as in the example posted here. I am not sure what the best fix for this would be... it seems like a tricky thing to solve. Perhaps we could assume that php files do not contain any html and just highlight them as php? |
As a workaround for this issue, you can: This will make delta assume that any file with a credit to @mjec for this fix UPDATE: if it doesn't work for you, it might be because your versions of delta and bat are incompatible. This might for instance happen if you installed one of them from a package manager that uses outdated versions. Try using the latest versions of both delta and bat. See: #895 |
Another improvement: the default Instead, you can use a custom monokai theme to get better coloring. Instructions for how to upgrade your monokai: |
I've also seen this issue, even though In this example, I've modified two Now, if I use bat to simply print those two files, I get this: In @dasl-'s workaround fixed |
@goodevilgenius That's because in the first example you have the short open tag |
@gpressutto5 Good observation. I hadn't actually noticed that the code within the That's a good catch. That would also explain why |
Somewhat related: #117 |
- Install bat directly from github rather than relying on packages in apt which may be out of date for older versions of Ubuntu - Use a fixed version of the PHP syntax file (see dandavison/delta#162 (comment))
@dandavison Would there be a way to enable the workaround purely in delta, without having to install bat? |
You don't need bat at run-time for this. But currently using |
Closing as a bug in upstream sublime syntax support (does anyone know if situation has improved since this discussion?). See also #117 |
The syntax highlighting for PHP only works when there's an opening tag
<?php
in the hunk.The text was updated successfully, but these errors were encountered: