Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#35479 closed defect (bug) (fixed)

Text editor not honoring paragraph markup

Reported by: arush's profile arush Owned by: arush's profile arush
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: TinyMCE Keywords:
Focuses: accessibility Cc:

Description

When writing a post in the text editor, any paragraph markup (<p> ... </p>) tags are stripped when switching to the visual editor. If switching back from the visual editor to the text editor, the code is stripped out of the post and has to be re-added. In other words, switching back and forth between editors appears to not be ideal, as you will lose formatting markup.

Attachments (2)

35479.patch (2.2 KB) - added by azaozz 9 years ago.
35479.2.patch (2.2 KB) - added by arush 9 years ago.
Adds corrected documentation in the help section as discussed in the comments, and expands WYSYWYG editor to "an editor that is similar to a word processor"

Download all attachments as: .zip

Change History (23)

#1 @swissspidy
9 years ago

  • Keywords close added

That's intentional. <p> tags are added automatically on output using wpautop().

#2 @afercia
9 years ago

  • Keywords close removed

Hi @arush :) yep the paragraph tags are stripped out and replaced with empty lines. That's a "feature", a bit confusing if reading the code with a screen reader yeah. When rendering the post on the front end, then paragraphs are added automatically. So when writing a post all you have to do is inserting an empty line between block of text and they will become paragraphs.

Maybe this feature should be better explained in the Help, any thoughts?

#3 @afercia
9 years ago

  • Focuses accessibility added

#4 @arush
9 years ago

If this is a feature, and not a bug, we should probably explain this better in the help. This was first brought to my attention by a sighted user, and it admittedly causes problems for myself as well, so something as to why it's intentional would also be of help. After all, if we're calling it a text editor, and telling people to write code in it, then those of us who write markup in it are going to expect that are markup is handled correctly.

#5 @arush
9 years ago

  • Status changed from new to closed

I get that we're going to block some tags, but if we're going to do that, can't we block things like <div> or <main> since those, for example, should be handled by the theme and not entered in by content managers?

#6 @johnbillion
9 years ago

  • Keywords 2nd-opinion added
  • Status changed from closed to reopened
  • Version 4.4.1 deleted

#7 @afercia
9 years ago

The Help text could be improved a bit. Currently, the relevant part is:

The Text mode allows you to enter HTML along with your post text. Line breaks will be converted to paragraphs automatically.

It does say that line breaks will be converted to paragraphs but it also says it "allows to enter HTML" and a <p> tag is HTML :) so for some users having paragraphs stripped out could be unexpected and a bit confusing.

Also, wondering how many users know what "WYSIWYG" means. The expanded form probably won't help so much. What about to change the sentence and just say what it does and not what it is?

https://cldup.com/bUMpSzokIr.png

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


9 years ago

#9 @azaozz
9 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 4.5

Agree we need better explanation of how the Text editor behaves (wpautop). We can update the text in 4.5 until strings freeze if there is a patch or suggestion :)

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


9 years ago

#11 @arush
9 years ago

Proposal for modified text:

The Text editor allows you to enter HTML along with your post text. While most tags are honored, the exceptions are the paragraph (<p> </p>) tag and the line break (<br> or <br> />) tag. This is because WordPress converts single presses of the "enter" key to <br>, and two presses of the "enter" key to <p>. If you are an accessibility professional who has spent time training your clients to enter properly formed HTML, and you do not want WordPress to make this decision for you or your clients, you can either disable the wpautop filter within your theme's functions.php file, or install a plugin that will disable this functionality and give you complete control of the markup you enter.

Last edited 9 years ago by arush (previous) (diff)

#12 @chriscct7
9 years ago

  • Owner set to arush
  • Status changed from reopened to assigned

#13 follow-up: @adamsilverstein
9 years ago

This text is confusing, good idea to clean it up. I'd like to keep this succinct while still better explaining how <br> and <p>` tags are stripped if you switch from text to visual editing modes. How about:

The Text mode allows you to enter most HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the visual editor.

#14 in reply to: ↑ 13 @arush
9 years ago

Replying to adamsilverstein:

This text is confusing, good idea to clean it up. I'd like to keep this succinct while still better explaining how <br> and <p>` tags are stripped if you switch from text to visual editing modes. How about:

The Text mode allows you to enter most HTML along with your post text. Note that <p> and <br> tags are not honored since single and double line breaks are automatically converted.

I think this is good. I've changed the text above somewhat since this applies regardless of editor.

Last edited 9 years ago by arush (previous) (diff)

#15 follow-up: @azaozz
9 years ago

Yep, that sounds good, only P and BR are converted when switching from Visual to Text, not the opposite :)

So how about:

The Text mode allows you to enter most HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the Text editor to make it less cluttered. They are converted back to tags in the Visual editor.

#16 in reply to: ↑ 15 @arush
9 years ago

Replying to azaozz:

Yep, that sounds good, only P and BR are converted when switching from Visual to Text, not the opposite :)

So how about:

The Text mode allows you to enter most HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the Text editor to make it less cluttered. They are converted back to tags in the Visual editor.

Yep, this'll do it.

#17 @azaozz
9 years ago

Maybe even better if there is some help for the Text editor:

The Text mode allows you to enter most HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the Text editor to make it less cluttered. When you type, a single line break can be used instead of typing <br>, and two line breaks instead of paragraph tags. The line breaks are converted back to tags in the Visual editor.

Will have to expand "WYSIWYG" too. Not sure how many people have ever heard that. Probably good if we can drop it completely.

#18 @arush
9 years ago

Yeah probably needs to be some help for the text editor. Hang on, let me grab the latest trunk and add. I think I can submit a patch for these.

@azaozz
9 years ago

#19 @azaozz
9 years ago

@arush sure, I got to here: https://core.trac.wordpress.org/attachment/ticket/35479/35479.patch. Feel free to edit :)

@arush
9 years ago

Adds corrected documentation in the help section as discussed in the comments, and expands WYSYWYG editor to "an editor that is similar to a word processor"

This ticket was mentioned in Slack in #core by arush. View the logs.


9 years ago

#21 @azaozz
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 36971:

Editor: correct and update the Visual and Text editors description in the screen help.

Props arush, adamsilverstein, azaozz.
Fixes #35479.

Note: See TracTickets for help on using tickets.