[wp-trac] [WordPress Trac] #18534: Synchronize block tags between PHP and JS versions of wpautop()

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 15 15:36:41 UTC 2012


#18534: Synchronize block tags between PHP and JS versions of wpautop()
---------------------------------+------------------
 Reporter:  SergeyBiryukov       |       Owner:
     Type:  defect (bug)         |      Status:  new
 Priority:  normal               |   Milestone:  3.5
Component:  Editor               |     Version:  3.2
 Severity:  normal               |  Resolution:
 Keywords:  has-patch 3.5-early  |
---------------------------------+------------------

Comment (by MarcusPope):

 Replying to [comment:17 azaozz]:
 > Yes, there are differences between the PHP and JS versions of autop, but
 they serve different purpose.

 Hmm, that's a low down dirty shame because if you save a post in HTML mode
 you sometimes get a different result than if you switch to Visual mode as
 a preview and then click save.  And that different result has historically
 been invalid markup.

 > Apart form making the Visual -> Text -> Visual editor switching a lot
 faster, the JS autop works together with TinyMCE's and browser's cleanup
 on loading the html code.

 Slightly faster but inconsistent vs slightly slower and consistent doesn't
 seem like a difficult choice to me.  Though I can't convey strongly enough
 how hopeless the task of cleaning up html with regex expresssions really
 is.

 But if the delay of a single ajax request is too daunting perhaps you
 could serve up an array of the same regex rules and the $allblocks
 variable via the wp_localize_script construct.  With only a cursory glance
 between the two it seems that most of them could share the exact same
 regex and replacement strings... the client side could then use them to
 create new RegExp js objects.  Doesn't work for functional replacements
 but it would reduce the duplicate logic and improve subsequent maintenance
 greatly.

 > Was actually looking at removing all </p> from the JS autop. That would
 simplify it a lot and may remove the need for blocklist.

 You might want to consider disabling both versions of wpautop altogether.
 We've done that on all of our wp installations for the last 5 client
 projects.  Letting TinyMCE do the work with its default paragraph
 insertion behavior has resulted in a lot less frustration with markup
 corruption.  Maybe it's time to reconsider starting from scratch given
 TinyMCE's improvements in recent years.

 As a proof of concept keep an eye out for version 1.2 of this plugin:
 http://wordpress.org/extend/plugins/preserved-html-editor-markup/

 It should be ready by the end of the week.  Not only will it preserve
 whitespace between the two tabs, it also disables autop entirely and gives
 users the option to use br newlines or use paragraph tags or both (where
 one return key press inserts a br tag and two return key presses inserts a
 new paragraph.)

 Anyway, good luck to you all on this one (and its related tickets.)

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


More information about the wp-trac mailing list