public
Last active

By default bbpress can be quite strict on the HTML it allows in posts (tags are whitelisted). The following loosens those restrictions and is taken from this post: http://buddypress.org/support/topic/tutorial-allow-more-html-tags-in-bp-forum-topics/

  • Download Gist
bbpress-kses.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<?php
function myprefix_kses_allowed_tags($input){
return array_merge( $input, array(
// paragraphs
'p' => array(
'style' => array()
),
'span' => array(
'style' => array()
),
 
// Links
'a' => array(
'href' => array(),
'title' => array(),
'rel' => array()
),
 
// Quotes
'blockquote' => array(
'cite' => array()
),
 
// Code
'code' => array(),
'pre' => array(),
 
// Formatting
'em' => array(),
'strong' => array(),
'del' => array( 'datetime' => true, ),
 
// Lists
'ul' => array(),
'ol' => array( 'start' => true, ),
'li' => array(),
 
// Images
'img' => array(
'src' => true,
'border' => true,
'alt' => true,
'height' => true,
'width' => true,
)
));
}
add_filter( 'bbp_kses_allowed_tags', 'myprefix_kses_allowed_tags', 999, 1 );
?>

Sorry Chris, it seems like I suck at copy and pasting. The first gist was missing both a return a array_merge. (Also I used add_action rather than add_filter - but that doesn't really make a difference).

I'm surprised a load of errors didn't get thrown in your screencast...

I put the above snippet in my site's utility plug-in - but i'm sure your theme's functions.php or equivalent would work as well. I haven't got a test site with bbPress & MarkDown installed, but I'll give it a test later.

Ooooh that helped =). So the paragraph tags thing is solved, but other stuff is kinda out of whack.

Here's a series of steps:

  1. User authors some totally legit Markdown

  2. Some it it renders OK, and no paragraphs anymore, but a lot of it does not.

    e.g. Three list items turned into to paragraphs, HTML stripped

  3. If you edit the very same post, what you get in the edit textarea is very different from what was posted.

  4. If you save that it's extra whacky.


What's cool is that WP-Markdown in the normal blog comments area of WordPress works perfectly:

So it's possible!


If you have time to work on this, I'd be happy to pay your freelance rate if you do that kinda thing. And of course have it just go into the open source plugin.

Mmm.... For no.2 have you checked the actual HTML - it could be bullet points without the styling (At least, I recall having to tweak bbPress' css). On a test site everything rendered correctly (for admin / author ).

  1. Yup, can confirm an issue with editing posts - will need to look into it, but seems like the paragraph tags are stripped, before HTML is converted into markdown (?). At least lsits s So when you edit it you're not seeing the appropriate markdown - and hence re-saving (4) will save those errors to the database.

(Editing from the admin doesn't produce these errors, so maybe bbPress is doing something somewhere to the post content when editing it from the frontend.)

I'll try and take a proper look at this over the weekend. I do take on freelance work, but this is a plug-in I actively use and (try to) maintain. So if you want to buy me a beer, you can, but there's obligation :).

Good thinking on checking the list styles, but sadly it really is not making a list out of them.

Maybe that's a good lead though - like why the heck would dashes get stripped before Markdown can see them?

I'll buy you many many cases of beer =)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.