-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Code/Preformatted/Verse Block: br tag and unintended space character added #58659
Comments
This problem does not occur in WP6.4, it occurs for the first time in WP6.5. So I added it to the project board. |
We should know the context node in which the @t-hamano the |
It seems that this was a misunderstanding on my part. This behavior was also the same in WP6.4.3. If so, I think the following three problems need to be solved, but is this possible?
|
Agreed here that we shouldn't have
I'm aware that this is a really inconsistent behavior between browsers, and something imposed on the
This is a new one I haven't seen before, as they are usually replaced by alternating |
Oh, it wasn't a double
This is a behavior that did not exist before. You should be able to reproduce this problem by inserting a code block and pressing the space bar repeatedly.
I have confirmed this on Windows OS and Chrome. I reproduce it in the screencast below. I tested it again and it seems that both 0de3959503366ef27829d72d621445d0.mp4 |
Thanks. That looked like Cleartype in the picture… I didn't doubt you saw this behavior, by the way - I only wanted to confirm where it was coming from.
Awesome, I was hoping and expecting you mean that.
That suggests to me it was #56855 and not #43204 which introduced this change. |
What do you think about temporarily reverting the format to the previous format as shown below to solve this problem? Or should I keep the current format and look for a more ideal solution? diff --git a/packages/block-library/src/code/block.json b/packages/block-library/src/code/block.json
index 4465c8554f..433ad5d262 100644
--- a/packages/block-library/src/code/block.json
+++ b/packages/block-library/src/code/block.json
@@ -8,8 +8,8 @@
"textdomain": "default",
"attributes": {
"content": {
- "type": "rich-text",
- "source": "rich-text",
+ "type": "string",
+ "source": "html",
"selector": "code",
"__unstablePreserveWhiteSpace": true
} |
What I was trying to say is that this doesn't seem like a result of the format change, but maybe I'm wrong. There was that separate work to alter the whitespace behavior which I suspect is more the culprit. On that note my thoughts about a revert don't matter that much; @ellatrix should have the full context and insight here to advise. |
Let's revert #56341, it anyway did not accomplish what I wanted. I'll check about the line breaks. |
The above should fix both these issues. |
I don't understand the line break issue. How do I reproduce the double line break issue? This is what I'm seeing: <!-- wp:code -->
<pre class="wp-block-code"><code><?php<br>function custom_the_title( $title, $id = null ) {<br> if ( in_category(' test', $id ) ) {<br> return '';<br> }<br> return $title;<br>}<br>add_filter( 'the_title', 'custom_the_title', 10, 2 );</code></pre>
<!-- /wp:code --> |
Inserts text containing line breaks ( fc3f0f7088a37b76a0398cbf1421a896.mp4 |
could this be an Edge/Windows-specific behavior? |
I don't have a Mac computer, so I'd appreciate it if you could test to see if this problem can be reproduced on MacOS. |
In my environment it looks like Screencast: 84a77202d379fa49974c45a6057b4809.mp4Full object data: |
So that's what I suspected :) It's |
Strange because we should be stripping |
Oh, I know what is happening. The |
This would be one way to fix I think #58805 |
So with these two fixes I think all issues here are addressed? |
By default it should be CR+LF(
Yes, I believe that once #58792 and #58805 are merged, all problems will be resolved. |
Description
I think the following issues are also related:
Code, Preformatted, and Verse blocks use the
pre
tag as wrapper elements. This tag is expected to display the text as is, so line breaks and spaces should be preserved.However, line breaks are replaced with
br
tags and spaces are replaced with 
entities, which may result in unintended display on the front end.From what I've researched, I suspect that #43204, which changed the format of RichText values, may be involved.
I'm concerned that this issue may also result in breaking changes to existing plugins that extend code blocks, as reported in #56855.
Step-by-step reproduction instructions
About double tags
Insert a code block and insert the sample code below.
When you switch to the code editor, you will see that line breaks have been replaced with
br
elements, as shown below. At the same time, the PHP opening tag (<
) is unintentionally replaced with<
.On the front end, it is not displayed correctly due to this double
br
tag.About incorrect spaces
Enter the text with spaces into the code editor. Another problem is that the space does not appear to appear unless you press the space bar several times, as shown in the screencast below.
cbb823dd441cc346d56c274820916fb3.mp4
In the front end, you should see spaces replaced with
&emsp:
as shown below.Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: