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

WordPress Trac noreply at wordpress.org
Thu Nov 7 09:19:32 UTC 2013


#25856: debug of wpautop function with Unit Tests
-------------------------+------------------------------
 Reporter:  mdbitz       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Formatting   |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------
Description changed by SergeyBiryukov:

Old description:

> == Cleanup / Refactor of wpautop function ==
>
> Upon review of the WordPress Trac needs-unit-test filter I saw that the
> wpautop function was needing both cleanup and unit tests. I have created
> a comprehensive test suite for the function that covers in my opinion the
> full breadth of use cases for the function. During this process I have
> been working on modifying the wpautop function to resolve out open
> defects and remove ''fix'' code that was placed to resolve an issue
> without resolving the underlying cause of the error.
>
> I've attached the following files for support of the changes.
>
> ''autop-20622.out'' --> OUTPUT from running the unit tests against
> current code base (revision 20622)
> ''autop-diff.out'' --> OUTPUT from running the unit test against
> modififed wpautop function as given in the diff.
> ''Autop.diff'' --> diff of changes made to the Autop test class :: Unit
> Tests
> ''formatting.diff'' --> diff of changes made to the formatting.php
> function file :: wpautop changes
>
> ''As a note I've added a trim call to the end of wpautop as it was always
> appending a new line, which I did not think was needed. This causes a
> good amount of test cases to fail as the expected output is not
> containing the additional new line given by current implementation.''
>
> ----
>
> == Enhancements / Fixes to wpautop function ==
>
> 1. Corrected core logic to identify when double new lines wrap open or
> close block element tags due to nested block level elements.  Original
> Logic adds \n\n before open tags and \n\n after close tags which allows
> for output of <p><div> TEXT</p> that is not correct, and had several
> patches implemented to attempt to fix.
>
> *Fixes ::  Formatting of Lists, Nested Lists, orphaned <p> tags
>
> 2. Added logic to not add <br/>tags after comments
>
> 3. Added logic to not convert \n for svg, math, style, select or script
> codes
>
> 4. Added logic to not format audio, video or object elements. This is
> implemented as the elements are in-line but can contain block level
> content for displaying in browsers that don't support the HTML5 elements.
>
> 5. case insensitive recognition of block tags
>
> 6. inclusion of variable re-naming as outlined in #25516
>
> ----
>
> == Overview of Tickets reviewed and covered by the Unit Tests ==
>
> Ticket  :  Current Status   : Summary
> #6877   :  Closed           :  large posts causes empty return
> #3476   :  Closed           :  Improper formatting of Object elements,
> additional <br/> and no ending </p>
> #3669   :  Closed           :  Don't insert <p> tags inside of block
> elements that only contain inline elements/text
> #6809   :  Closed           : wpautop correctly handles auto <p> of basic
> text
> #11024  :  Closed           : Incorrect handling of div tags with nested
> inline tags
> #1305   :  Closed           : Handling of <code> blocks>
> #1706   :  Closed           : <p> tags with attributes introduce
> additional <br/>
> #2285  :  Closed            :  Strip excessive <br /> in content
> #2813  :  Closed            :  <br> elements added instead of <br />
> #3007  :  Closed            :  Spacing of text in block elments reveals
> improper handling of nested elements
> #3035  :  Closed            : Extra <br/> tags introduced in Object tags.
> #3238  :  Closed            :  Dangling <p> tags, no closing
> #3621  :  Closed            :  Don't format new lines in Script and
> Object tags
> #3854  :  Closed            :  Don't format new lines in Script and Style
> tags
> #3935  :  Closed (wf)       :  Erroneous </p> tags added to the content
> '''has fix'''
> #3952  :  Closed            :  Don't autop hr tags
> #5250  :  OPEN              :  incorrect handling of lists + nested Lists
> '''has fix'''
> #7937  :  Closed            :  incorrect handling of inline tags
> #7988  :  Closed (wf)       :  incorrect handling of nested tags
> '''has fix'''
> #8644  :  Closed            :  HTML5 block elements
> #10033 :  OPEN              :  autop does not handle Comments    '''has
> fix'''  *also contains wptexturize details that I am not sure are fully
> closed out.
> #11257 : Closed            : autop errors out on large content
> #11678  : OPEN              : autop does not recognize upper tags
> '''has fix'''
> #13340  : OPEN              : nested MATH tag handling
> '''has fix'''
> #2833    : OPEN             : No formating Style and Script tags
> '''has fix'''
> #4298    : Accepted         : handling of tags with attributes on new
> lines     '''fix already existed'''
> #3833    : OPEN             : incorrect </p> tags in block elements
> (explicitly blockquote)    '''has fix'''
> #6041    : Closed           : incorrect handling of DL lists and DT,DD
> elements
> #9437    : OPEN             : dont modify SVG content          '''has
> fix'''
> #10247   : Closed           : no new lines in Video, Audio, Source
> #4857    : OPEN             : incorrect autop logic         '''has fix'''
> #15918   : OPEN             : incorrect handling of nested tags
> '''has fix'''
> #16456   : Closed           : input is not block level
> #3054    :  Closed          : input is not block level
> #16790   :  Reviewing       : functional specifications
> '''can close'''
> #18534   : Closed           :  noscript are block level
> #20444   : OPEN             : Single line handling (nested block level
> issue)     '''has fix'''
> #18136   : OPEN             : extra </p> tags being added due to white
> space    '''has fix'''
> #23135   : OPEN             : block element filter           '''close as
> won't fix'''
> #18807   : Closed           : samp is not block level
> #25516   : OPEN             : variable name changes     '''changes
> included'''
> #9305    : Closed           : handling of empty content
> #6218    : Closed           : handling of empty content
> #11947   : Closed           : no formating of select options  '''has
> fix'''
> #12335   : Closed           : HTML5 Block Elements
>
> == Tickets concerning ShortCode handling ==
> Ticket  :  Current Status
> #12061 : OPEN
> #6984   : OPEN
> #21689  : OPEN
> #24085  : OPEN
> #24846  : OPEN
>
> ''Currently the wpautop function does not concern itself with shortcodes.
> I suggest that 12061 remain open as a future enhancement and that other
> tickets can be closed referending 12061 unless there is issues with
> '''shortcode_unatop''' or other functions used.''
>
> == Tickets Reviewed but Ignored/ Not Tested/ Duplicate ==
>
> '''Ticket'''  :  '''Current Status''' :  '''Summary'''
> #11249  :  Closed         :  standalone function
> #10490  :  Closed         :  Duplicate of 10082
> #9218   :  Closed         :  Duplicate of 4298
> #19934  :  Closed         : Duplicate of 16456
> #18330  :  Rejected       : Enhancement
> #18514  :  Rejected       : Enhancement
> #23858  :  Closed         : Duplicate of 18807
> #23375  :  Closed         : Duplicate of 18807

New description:

 == Cleanup / Refactor of wpautop function ==

 Upon review of the WordPress Trac needs-unit-test filter I saw that the
 wpautop function was needing both cleanup and unit tests. I have created a
 comprehensive test suite for the function that covers in my opinion the
 full breadth of use cases for the function. During this process I have
 been working on modifying the wpautop function to resolve out open defects
 and remove ''fix'' code that was placed to resolve an issue without
 resolving the underlying cause of the error.

 I've attached the following files for support of the changes.

 ''autop-20622.out'' --> OUTPUT from running the unit tests against current
 code base (revision 20622)
 ''autop-diff.out'' --> OUTPUT from running the unit test against modififed
 wpautop function as given in the diff.
 ''Autop.diff'' --> diff of changes made to the Autop test class :: Unit
 Tests
 ''formatting.diff'' --> diff of changes made to the formatting.php
 function file :: wpautop changes

 ''As a note I've added a trim call to the end of wpautop as it was always
 appending a new line, which I did not think was needed. This causes a good
 amount of test cases to fail as the expected output is not containing the
 additional new line given by current implementation.''

 ----

 == Enhancements / Fixes to wpautop function ==

 1. Corrected core logic to identify when double new lines wrap open or
 close block element tags due to nested block level elements.  Original
 Logic adds \n\n before open tags and \n\n after close tags which allows
 for output of <p><div> TEXT</p> that is not correct, and had several
 patches implemented to attempt to fix.

 *Fixes ::  Formatting of Lists, Nested Lists, orphaned <p> tags

 2. Added logic to not add <br/>tags after comments

 3. Added logic to not convert \n for svg, math, style, select or script
 codes

 4. Added logic to not format audio, video or object elements. This is
 implemented as the elements are in-line but can contain block level
 content for displaying in browsers that don't support the HTML5 elements.

 5. case insensitive recognition of block tags

 6. inclusion of variable re-naming as outlined in #25516

 ----

 == Overview of Tickets reviewed and covered by the Unit Tests ==

 Ticket  :  Current Status   : Summary
 #6877   :  Closed           :  large posts causes empty return
 #3476   :  Closed           :  Improper formatting of Object elements,
 additional <br/> and no ending </p>
 #3669   :  Closed           :  Don't insert <p> tags inside of block
 elements that only contain inline elements/text
 #6809   :  Closed           : wpautop correctly handles auto <p> of basic
 text
 #11024  :  Closed           : Incorrect handling of div tags with nested
 inline tags
 #1305   :  Closed           : Handling of <code> blocks>
 #1706   :  Closed           : <p> tags with attributes introduce
 additional <br/>
 #2285  :  Closed            :  Strip excessive <br /> in content
 #2813  :  Closed            :  <br> elements added instead of <br />
 #3007  :  Closed            :  Spacing of text in block elments reveals
 improper handling of nested elements
 #3035  :  Closed            : Extra <br/> tags introduced in Object tags.
 #3238  :  Closed            :  Dangling <p> tags, no closing
 #3621  :  Closed            :  Don't format new lines in Script and Object
 tags
 #3854  :  Closed            :  Don't format new lines in Script and Style
 tags
 #3935  :  Closed (wf)       :  Erroneous </p> tags added to the content
 '''has fix'''
 #3952  :  Closed            :  Don't autop hr tags
 #5250  :  OPEN              :  incorrect handling of lists + nested Lists
 '''has fix'''
 #7937  :  Closed            :  incorrect handling of inline tags
 #7988  :  Closed (wf)       :  incorrect handling of nested tags    '''has
 fix'''
 #8644  :  Closed            :  HTML5 block elements
 #10033 :  OPEN              :  autop does not handle Comments    '''has
 fix'''  *also contains wptexturize details that I am not sure are fully
 closed out.
 #11257 : Closed            : autop errors out on large content
 #11678  : OPEN              : autop does not recognize upper tags
 '''has fix'''
 #13340  : OPEN              : nested MATH tag handling
 '''has fix'''
 #2833    : OPEN             : No formating Style and Script tags
 '''has fix'''
 #4298    : Accepted         : handling of tags with attributes on new
 lines     '''fix already existed'''
 #3833    : OPEN             : incorrect </p> tags in block elements
 (explicitly blockquote)    '''has fix'''
 #6041    : Closed           : incorrect handling of DL lists and DT,DD
 elements
 #9437    : OPEN             : dont modify SVG content          '''has
 fix'''
 #10247   : Closed           : no new lines in Video, Audio, Source
 #4857    : OPEN             : incorrect autop logic         '''has fix'''
 #15918   : OPEN             : incorrect handling of nested tags
 '''has fix'''
 #16456   : Closed           : input is not block level
 #3054    :  Closed          : input is not block level
 #16790   :  Reviewing       : functional specifications
 '''can close'''
 #18534   : Closed           :  noscript are block level
 #20444   : OPEN             : Single line handling (nested block level
 issue)     '''has fix'''
 #18136   : OPEN             : extra </p> tags being added due to white
 space    '''has fix'''
 #23135   : OPEN             : block element filter           '''close as
 won't fix'''
 #18807   : Closed           : samp is not block level
 #25516   : OPEN             : variable name changes     '''changes
 included'''
 #9305    : Closed           : handling of empty content
 #6218    : Closed           : handling of empty content
 #11947   : Closed           : no formating of select options  '''has
 fix'''
 #12335   : Closed           : HTML5 Block Elements

 == Tickets concerning ShortCode handling ==
 Ticket  :  Current Status
 #12061 : OPEN
 #6984   : OPEN
 #21689  : OPEN
 #24085  : OPEN
 #24846  : OPEN

 ''Currently the wpautop function does not concern itself with shortcodes.
 I suggest that 12061 remain open as a future enhancement and that other
 tickets can be closed referending 12061 unless there is issues with
 '''shortcode_unatop''' or other functions used.''

 == Tickets Reviewed but Ignored/ Not Tested/ Duplicate ==

 '''Ticket'''  :  '''Current Status''' :  '''Summary'''
 #11249  :  Closed         :  standalone function
 #10490  :  Closed         :  Duplicate of #10082
 #9218   :  Closed         :  Duplicate of #4298
 #19934  :  Closed         : Duplicate of #16456
 #18330  :  Rejected       : Enhancement
 #18514  :  Rejected       : Enhancement
 #23858  :  Closed         : Duplicate of #18807
 #23375  :  Closed         : Duplicate of #18807

--

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


More information about the wp-trac mailing list