-
Notifications
You must be signed in to change notification settings - Fork 4.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
Footnotes: only replace attribute if footnotes were detected #63935
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +11 B (0%) Total Size: 1.78 MB
ℹ️ View Unchanged
|
I didn't test but the changes make sense to me |
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.
The code looks good, and the fix works correctly in my testing.
Thank you, @ellatrix! 👍
Maybe I should add an e2e test with a test block using PlainText |
2611959
to
6a29997
Compare
d03871b
to
6a29997
Compare
…ss#63935) Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: sgomes <sergiomdgomes@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
What?
Currently the function
updateFootnotesFromMeta
(which updates footnotes order when block order changes) seems to always update the block attribute if it's a string or RichTextData instance, even if no footnotes were detected. This is causing some issues with blocks that plain text string with new lines, which RichText will read as line break, and then serialise the line breaks in HTML. To prevent this, we can check if footnotes were detected at all.An alternative fix is to stop processing string attributes, and only process RichTextData attributes. Footnotes were added before we had this new data type, at the time rich text attributes were also plain strings. But I think some more work is needed to guarantee that rich text attributes are always RichTextData instances.
Why?
How?
Testing Instructions
Install this plugin: https://wordpress.org/plugins/syntaxhighlighter/
Add this in the code editor:
Now switch back to visual and add a footnote to the paragraph. The line breaks in the code block should not be converted to BR elements.
Testing Instructions for Keyboard
Screenshots or screencast