[wp-trac] [WordPress Trac] #30986: Consider using an abstract syntax tree for wpautop

WordPress Trac noreply at wordpress.org
Tue Jan 13 23:22:28 UTC 2015


#30986: Consider using an abstract syntax tree for wpautop
-------------------------+------------------------------
 Reporter:  ericlewis    |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Formatting   |     Version:  0.71
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by ericlewis):

 attachment:30986.2.diff is a patch against core which includes my second
 iteration.

 The internal logic is easier to read. It now adds paragraph tags to
 roughly the proper locations.

 Unit tests fail for two reasons:
 * `wpautop()` performs string trimming and `\n` stripping that the class
 would need to match.
 * DOMDocument replaces characters with HTML entities, which creates valid
 HTML but we might consider reversing for back-compat.

 attachment:30986.2.diff also includes benchmarking versus wpautop().

 Replying to [comment:2 dd32]:
 > 1. Speed; `wpautop()` is called on the front end, needs to be a decent
 speed

 Here's benchmark results from my basic test:

 {{{
 Seconds for 10000 wpautop() invocations: 0.020344972610474
 Seconds for 10000 WP_AutoP class invocations: 0.34989809989929
 }}}

 So it looks like the class is 10x slower than `wpautop()` in its current
 form.

 Replying to [comment:2 dd32]:
 > Availability; DOMDocument can be disabled in PHP, as can other XML
 parsing tools, and we've got conditionals on it's use elsewhere within
 core already I believe.

 That is a bummer. I wonder if this is a dealbreaker.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30986#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list