-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Align highlight_string|file with HTML standard and modern browsers #11913
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
Conversation
I think this can't target stable branches due to the BC break, both for the internal function exposed as ZEND_API and also for the userland behaviour. |
According to the documentation the HTML markup can change at any time. https://www.php.net/manual/en/function.highlight-string.php#refsect1-function.highlight-string-notes
So I think it's ok to go into minor. There should be no noticeable change in the visual output. The only difference is that the output is now block instead of inline. |
Ah ok, wasn't aware of the note. |
I see no reason to target a stable branch with something that hasn't been touched in decades. What's wrong with 8.3? |
Because technically it's a bug fix. People did complain some time ago that the output of this when displayed in the browser, cannot be cleanly copied. This isn't just a stylistic change, but rather meant to fix the bug. |
9924c50
to
88fc877
Compare
I have a quick question: why is |
Excellent question. I thought of doing the same, but I noticed that we used 4 NBSPs before. If I changed it now to a proper tab, it would change the output, because the tab is a wider character than 4 NBSP. Test it yourself.
|
The size of a tab in HTML is configurable using https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if using a separate <code>
tag per line is actually more correct than the current version. MDN says:
To represent multiple lines of code, wrap the
<code>
element within a<pre>
element.
Which is phrased as a single <code>
element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zend/zend_highlight.c
Outdated
zend_printf("</span>"); | ||
zend_printf("</code>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those should still be span
elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you are right. I checked how it works on Stack Overflow and they do it exactly like this. I changed it now.
But why not? The documentation clearly states that the HTML cannot be relied upon. So as long as the actual visual output isn't changed, there should be no issue. Of course, if RMs do not agree, then let's do it in 8.3. |
Correct, but then it says:
|
The documentation is not the spec, the documentation reflects, and always will, the behaviour of the engine. So the argument "the documentation says something" does not hold up. Because if it did, dynamics properties should/could have been removed whenever, as it wasn't documented until they were deprecated. And yes the output should not be relied upon, but changing this in a patch version makes no sense. We already have people complain about tests breaking to output changes when fixing actual bugs, so I really don't want to hear this for something that is just a cosmetic change. |
Nothing in the living spec document seems to indicate this being valid markup: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-code-element and https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element |
I agree that this should not go to stable branches. I'm fine with 8.3 though. |
88fc877
to
8343be4
Compare
I rebased it against master, since this is what everyone agrees should be the target branch. |
9f2fd55
to
950b893
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add an entry into UPGRADING before merging (or after) about the format change.
case '\t': | ||
ZEND_PUTS(" "); | ||
ZEND_PUTS(" "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I'm a fan of replacing tabs by 4 spaces, but that's by the by.
PHP 8.3 changed the details of highlighting PHP code[1], basically like we did[2] at roughly the same time. However, both don't work well together, so we avoid that. [1] <php/php-src#11913> [2] <php#79>
PHP 8.3 changed the details of highlighting PHP code[1], basically like we did[2] at roughly the same time. However, both don't work well together, so we avoid that. [1] <php/php-src#11913> [2] <#79>
See php/phd#79 (comment)
This PR fixes:
<br>
output\n
output<code>
use<pre>
<span>
use<code>
<code>
(old<span>
)