[wp-trac] [WordPress Trac] #25856: debug of wpautop function with Unit Tests

WordPress Trac noreply at wordpress.org
Mon Dec 23 21:19:39 UTC 2013


#25856: debug of wpautop function with Unit Tests
-------------------------+-----------------------------
 Reporter:  mdbitz       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  Formatting   |     Version:  3.8
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+-----------------------------

Comment (by azaozz):

 I'm also very happy to see these patches, really good work! It is about
 time to make wpautop() fully HTML 5.0 compliant.

 Some "first-look" notes:
 - There are no tags like `<header />`, `<footer />`, `<menu />`, etc. in
 HTML 5.0. All of these are completely invalid as they *require* closing
 tags, and the self-closing ending is optional. The tests should use valid
 tags.
 - I'm [https://core.trac.wordpress.org/ticket/13237 alot] unhappy about
 removing the humorous var names. Why?? :)
 - The purpose of this function is to replace line breaks with `<p>`s.
 Don't think it should be creating `<p>`s from thin air when there are no
 line breaks, or prettifying the html. It is quite expensive at the moment,
 making it even more expensive is unwise imho.
 - There is a typo in `$blocklist // List of Blocking elements (minus p)`,
 it still contains `|p|`.
 - The part `preg_replace('!(<' . $allblocks . '[^>]*\/>)!i', "$1\n\n"...`
 is not needed. As far as I know there aren't any block elements in HTML
 5.0 that don't require a closing tag.
 - Not sure which tags `preg_match( '/<p[^>]*>.*?<\/p[^>]*>/si'...` is
 supposed to match. Currently it matches `<p>|<pre>|<param>|<progress>`.
 Doesn't look like this was intended. If we need only `<p>`, the start of
 the regex would be `/<p(?: [^>]+)?>...`, not sure why the closing tag is
 expanded.
 - Don't see a point in preserving formatting/line breaks in `<audio>`,
 `<video>` and `<object>`. The only HTML tag where this matters is `<pre>`.
 All line breaks in the other tags should probably be stripped, saving some
 processing time. Further, this will fail for `<object>` as it can be
 nested and often is.

 There are no "self-closing" tags in HTML 5.0. Instead some closing tags
 can be [http://www.w3.org/TR/html5/syntax.html#syntax-tag-omission
 omitted]. Among them is `<p>`. Been thinking whether it is practical to
 stop outputting `</p>`s from wpautop(). This has been supported in all
 browsers since the early days (mid 90's) and works really well. It was
 "invalid" in the XHTML 1.0 days but that time is long gone.

 Another thing I've been thinking about is to return early from wpautop()
 when there are no line breaks in the source. This will not only make it
 faster for one-paragraph posts, but would allow for storing "full-html"
 content that would bypass autop automatically.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25856#comment:18>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list