WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#7511 closed defect (bug) (invalid)

Code tags get messed up

Reported by: da3rX Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.6
Component: General Keywords:
Focuses: Cc:
PR Number:

Description

Wordpress doesn't like empty lines between code tags.

<code>
a

b

c
</code>

Turns into:

<code>
a</code>

b

c

Change History (7)

#1 @azaozz
11 years ago

  • Milestone 2.6.1 deleted
  • Resolution set to invalid
  • Status changed from new to closed

<code> is an "inline" tag, like <strong> and <em>. More details:
Phrase elements: EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, and ACRONYM
http://www.w3.org/TR/html401/struct/text.html#h-9.2.1

According to the W3C specification blank spaces and line breaks are ignored in it. The only tag that preserves them is the <pre> tag and that is working well in both editors and autop.

#2 follow-up: @rdworth
11 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

The fact that newlines aren't preserved means

<code>
a

b

c
</code>

could reasonably become

<code>a b c</code>

but not

<code>a</code> b c

as the original description has.

#3 in reply to: ↑ 2 @azaozz
11 years ago

  • Component changed from TinyMCE to General
  • Resolution set to invalid
  • Status changed from reopened to closed

When using the HTML editor pressing Enter once would insert BR tag, pressing it twice would insert P tag. Since you can't wrap paragraphs in <code>, it is limited only to the first paragraph.

If you want to stop converting new lines to paragraphs, you will have to turn off autop (not recommended).

#4 @caesarsgrunt
11 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

Shouldn't the converter recognise when it is inside a <code> element and not convert newlines to <p>s inside it?

#5 @Viper007Bond
11 years ago

<code> is an inline tag. Shouldn't it not have line breaks inside of it?

#6 @Viper007Bond
11 years ago

Also -- there are TONS of plugins for pasting code. Why not use one of those? That way you don't have to manual convert to HTML entities, i.e. like < to &lt;.

#7 @rmccue
11 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.