[wp-trac] [WordPress Trac] #2833: wpautop breaks style and script tags

WordPress Trac wp-trac at lists.automattic.com
Sat Jun 17 20:36:00 GMT 2006


#2833: wpautop breaks style and script tags
---------------------+------------------------------------------------------
 Reporter:  Nazgul   |       Owner:  anonymous                    
     Type:  defect   |      Status:  new                          
 Priority:  low      |   Milestone:  2.1                          
Component:  General  |     Version:  2.0.3                        
 Severity:  normal   |    Keywords:  wpautop break script style br
---------------------+------------------------------------------------------
 When I create a post in which I want to include Javascript or some styles,
 WordPress 'breaks'when showing those posts, because all newlines in the
 SCRIPT and STYLE tag are converted into BR tags.

 Example:
 {{{
 <style type="text/css>
 .matt { color: #FFFFFF; }
 </style>
 }}}
 Becomes:
 {{{
 <style type="text/css><br />
 .matt { color: #FFFFFF; }<br />
 </style><br />
 }}}

 And:
 {{{
 <script type="text/javascript"><!--
 google_ad_client = "xxxxxxxx";
 google_ad_width = 120;
 google_ad_height = 60;
 google_ad_format = "120x60_as_rimg";
 google_cpa_choice = "CAAQ2eOZzgEaCD4zuVkdzt_CKI-293M";
 //--></script>
 }}}
 Becomes
 {{{
 <script type="text/javascript"><!--<br />
 google_ad_client = "xxxxxxxx";<br />
 google_ad_width = 120;<br />
 google_ad_height = 60;<br />
 google_ad_format = "120x60_as_rimg";<br />
 google_cpa_choice = "CAAQ2eOZzgEaCD4zuVkdzt_CKI-293M";<br />
 //--></script><br />
 }}}

 This happens because wpautop adds those BR tags to the post. (As it
 should, just not within STYLE or SCRIPT tags.)

 I've made a (temporary?) workaround for this by creating a pre and post
 event for wpautop, which substitute the necessary newlines by a temporary
 value in the pre event and placing them back in the post event. Although I
 think this should be incorporated in wpautop itself.

 See also: http://wordpress.org/support/topic/76433 and
 http://wordpress.org/support/topic/76297

 While searching trac I also found ticket #2346, which is about the same
 problem, but which was for 2.0 and self-closed by the submitter?

 P.S. I have TinyMCE turned of.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2833>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list