Title: [Plugin: Sunburst Code Prettify] Dealing with WordPress&#039;s auto formatting
Last modified: August 20, 2016

---

# [Plugin: Sunburst Code Prettify] Dealing with WordPress's auto formatting

 *  Resolved [Morcarag](https://wordpress.org/support/users/morcarag/)
 * (@morcarag)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-sunburst-code-prettify-dealing-with-wordpresss-auto-formatting/)
 * So I’m really liking the idea of the plugin, but I’m running into an issue of
   dealing with the auto formatting that WordPress adds to all it’s stuff. As a 
   simple example I want to do the following in a post, inside the HTML editor for
   that post:
 *     ```
       [prettify]
       <div id="home_outer_wrapper">
       	<div id="home_inner_wrapper">
       	</div>
       </div>
       [/prettify]
       ```
   
 * If I use the plugin as is I get no output because the divs are rendered. I can
   go into the plugin modify the sunprettify_shortcode function to improve things(
   though I still get a lot of issues with WordPress adding p tags, br tags, and
   other gunk. I’m wondering if I’m missing anything on how I should be using this
   plugin.
 * My (hackish) modifications to the sunprettify_shortcode function:
 *     ```
       function sunprettify_shortcode( $atts, $content = null ) {
          extract( shortcode_atts( array(
             'class' => 'prettify',
             ), $atts ) );
   
          //START modification
          $content = str_replace('<p>', '', $content);
          $content = str_replace('</p>', '', $content);
          $content = str_replace('<br/>', '', $content);
          $content = str_replace('<br />', '', $content);
          $content = str_replace('<br>', '', $content);
          $content = str_replace('<', '<', $content);
          $content = str_replace('>', '>', $content);
          //END modification
   
          return '<pre class="prettyprint ' . esc_attr($class) . '">' . $content . '</pre>';
       }
       add_shortcode( 'prettify', 'sunprettify_shortcode' );
       ```
   
 * [http://wordpress.org/extend/plugins/sunburst-code-prettify/](http://wordpress.org/extend/plugins/sunburst-code-prettify/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Rachel Baker](https://wordpress.org/support/users/rachelbaker/)
 * (@rachelbaker)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-sunburst-code-prettify-dealing-with-wordpresss-auto-formatting/#post-2703996)
 * Morcarag,
 * For code you want to enter into the html editor, you can just use the pre or 
   code tags around your code
    `<pre class="prettyprint">``</pre>`
 * Example:
 *     ```
       <pre class="prettyprint lang-php">
       $ideas_posts = $wpdb->get_results(
       "SELECT * FROM $wpdb->posts
       WHERE post_status = 'draft'
       AND post_type = 'post' ORDER BY post_date DESC");
       </pre>
       <pre class="prettyprint lang-php">
       foreach ($ideas_posts as $memberpost): </pre>
       ```
   
 *  Plugin Author [Rachel Baker](https://wordpress.org/support/users/rachelbaker/)
 * (@rachelbaker)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-sunburst-code-prettify-dealing-with-wordpresss-auto-formatting/#post-2704025)
 * Morcarag,
 * I have been thinking about this, and you are right – adding the content stripping
   for the visual editor would be helpful for the shortcode. I will add it to the
   next release.
 * Thank you for your recommendation and code contribution.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Sunburst Code Prettify] Dealing with WordPress's auto formatting’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/sunburst-code-prettify.svg)
 * [Sunburst Code Prettify](https://wordpress.org/plugins/sunburst-code-prettify/)
 * [Support Threads](https://wordpress.org/support/plugin/sunburst-code-prettify/)
 * [Active Topics](https://wordpress.org/support/plugin/sunburst-code-prettify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sunburst-code-prettify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sunburst-code-prettify/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Rachel Baker](https://wordpress.org/support/users/rachelbaker/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-sunburst-code-prettify-dealing-with-wordpresss-auto-formatting/#post-2704025)
 * Status: resolved