-
Notifications
You must be signed in to change notification settings - Fork 50
Drop \n
when highlighting
#79
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
Actual newlines will be replaced by `<br />` during highlighting and the `\n` in the boilerplate conflicts with `white-space: pre;`. see php/doc-en#2648
For an easier understanding, it would be nice if you could provide examples. How exactly does it interfere? Why do we now need to remove the |
To properly include the original indentation of stuff output of
formatting is insufficient, because the selector doesn't match. However putting Without the newlines: |
Honestly, we should probably stop using We could fix the function within php-src because we technically are allowed to by the PHP documentation:
I think it would be the best fix, but we would need to wait for the next minor PHP release and then upgrade the environment for php.net. The fix would be easy:
No more breaking HTML standard, no more adjustments of the output, and no more CSS styles on php.net. For the time being, I guess we could accept your PR. |
@@ -63,7 +63,10 @@ public function highlight($text, $role, $format) | |||
|
|||
if ($role == 'php') { | |||
try { | |||
return str_replace(' ', ' ', highlight_string($text, 1)); |
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.
str_replace()
can also take an array of values to replace and an array of what those values should be, why not just use that?
But the issue seems to be more that \n
tags before and after are being converted to <br>
so wouldn't it make more sense to just ltrim()
new lines of the $text
variable?
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.
str_replace()
can also take an array of values to replace and an array of what those values should be, why not just use that?
see #79 (comment)
But the issue seems to be more that \n tags before and after are being converted to
so wouldn't it make more sense to just ltrim() new lines of the $text variable?
This wouldn't work, because the extra newlines are inserted by highlight_string()
, namely here:
and here:
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.
sigh why is it doing that >.>
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>
In a second step the CSS will need to be adjusted.
Actual newlines will be replaced by
<br />
during highlighting and the\n
in the boilerplate conflicts withwhite-space: pre;
.see php/doc-en#2648