Clearing the text from the shortcode

I’m assuming those shortcodes are being added by the Visual Composer plugin. I’ve tried a few things for dealing with them. There are three different approaches in the ‘Dealing with WordPress shortcodes’ section of this topic: WP Discourse Plugin Tips and Tricks

From what I remember, with Visual Composer shortcodes, calling do_shortcode doesn’t work. The shortcode is processed, but a bunch of whitespace is added to the markup and it gets interpreted as code by Discourse.

If you need to have the content of the shortcodes published to Discourse, probably the first approach in that topic would be the best. If it’s not giving you the formatting that you need, the regular expression could be improved so that it replaces certain shortcodes with <div></div> tags.

// Removes anything that looks like a shortcode. This will remove anything in the post that
// occurs inside of brackets `[...]`.
// Replace 'my_namespace' with your namespace.
add_filter( 'wp_discourse_excerpt', 'my_namespace_remove_shortcodes' );
function my_namespace_remove_shortcodes( $excerpt ) {
    $excerpt = preg_replace( '/\[.*\]/', '', $excerpt );

    return $excerpt;
}