Make WordPress Core

Opened 12 years ago

Closed 7 months ago

#27076 closed defect (bug) (wontfix)

double newlines inserted before captions

Reported by: arupqfjm's profile arupqfjm Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.6
Component: Editor Keywords: has-patch
Focuses: ui, javascript, administration Cc:

Description

Steps to reproduce:

  • Upload some picture in the library and add some caption to it
  • Edit a post/page using the visual editor and, after some text, insert the picture using the add media button, so a "caption" shorttag is created
  • Go into text editing
  • Suppress the two newlines that appeared before the "caption" shorttag
  • Go into visual mode
  • Go into text mode: the newlines reappeared

It is important to put something before the picture inserted in order to reproduce the bug, because the two newlines are not inserted if it is at the very beginning of a post/page.

This is annoying for example in a table with top-aligned cells, if in a cell you have some text, and in the cell just to the right you have a "caption", then the two won't be aligned, since the newlines are converted to an empty paragraph during the rendering.

From what I saw, the issue could be fixed by just removing the line n° 124 in wp-admin/js/editor.js:
content = content.replace( /\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n' );

Attachments (1)

27076.diff (647 bytes) - added by arupqfjm 12 years ago.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
12 years ago

  • Version changed from 3.8.1 to 2.6

Introduced in [8239]. Related: [8260], [8313].

#2 @arupqfjm
12 years ago

  • Focuses ui javascript administration added
  • Keywords dev-feedback ui-feedback ux-feedback added

#3 @arupqfjm
12 years ago

  • Keywords has-patch added

@arupqfjm
12 years ago

#4 @arupqfjm
12 years ago

  • Keywords needs-testing added

#5 @chriscct7
10 years ago

  • Keywords ui-feedback ux-feedback removed

#6 follow-up: @SirLouen
7 months ago

  • Keywords 2nd-opinion needs-refresh added; dev-feedback needs-testing removed

@azaozz added this line back in the day 17 years and the patch (which is not applying any more, needs-refresh, is 11 years ago)

#7 in reply to: ↑ 6 @azaozz
7 months ago

  • Keywords 2nd-opinion needs-refresh removed
  • Resolution set to wontfix
  • Status changed from new to closed

Replying to SirLouen:

@azaozz added this line back in the day

This seems needed to ensure captions in the old editor work as expected. Changing it now might break them, and that code is in "deep maintenance" mode. Thinking it is safe to close it after 17 years. The behaviour is correct in most cases, and can be corrected by hand if absolutely necessary.

Note: See TracTickets for help on using tickets.