-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix the PHP language #1100
Fix the PHP language #1100
Conversation
I don't think that's a huge problem (they can use |
Yes that is one option, but I think it is more intuitive to assume that it is all PHP in that case. For example someone could use small snippets of PHP code between paragraphs on a blog to explain a larger file: $test = "<div>" . $_SERVER['PHP_SELF'] . "</div>"; If we switch to <?php $test = "<div>" . $_SERVER['PHP_SELF'] . "</div>"; ?> If there is no PHP code at all, people should use |
Ah yeah, excellent point! Completely agree. |
@zeitgeist87 Sorry for the looong time before review. This looks ok to me! ;) Feel free to merge. |
This patch is an attempt to fix the PHP language, when it is combined with markup. The problem is, that markup has a higher priority than all other tokens. This leads to weird errors, where HTML tags are highlighted inside of comments PrismJS#197. One solution to this was to set the `greedy` flag for the comment token, but this leads to far worse errors like PrismJS#1097. This patch should fix both issues PrismJS#197 and PrismJS#1097, by switching the grammar to markup on the fly. One potential problem is, that it relies on the `<?php` tag to detect if markup is present. So if a PHP file contains only markup and no PHP code at all, the result will look broken.
highlighted as punctuation in JavaScript and CSS.
@Golmote Thanks again for the review! Merging... |
This patch is an attempt to fix the PHP language, when it is combined
with markup.
The problem is, that markup has a higher priority than all other tokens.
This leads to weird errors, where HTML tags are highlighted inside of
comments #197. One solution to this was to set the
greedy
flag for thecomment token, but this leads to far worse errors like #1097.
This patch should fix both issues #197 and #1097, by switching the
grammar to markup on the fly. One potential problem is, that it relies
on the
<?php
tag to detect if markup is present. So if a PHP filecontains only markup and no PHP code at all, the result will look
broken.