-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Steps to preproduce
- Install bbPress
- Install WP-MarkDown, enable markdown for bbPress
- Create a topic and a reply. (Saves correctly* )
- Edit the reply - markdown is corrupted.
The HTML coming of the database is fine, but after this HTML is converted into MarkDown for the editor it becomes corrupted, specifically by: bbp_code_trick_reverse() hooked onto the (same) filter, but later in the queue, bbp_get_form_{type}_content.
This function seems to reverse the effects of bbp_code_trick() which is applied as the content is saved to the database (and after MarkDown is converted into HTML). Oddly, this has function has no adverse effect, only its reverse.
From what I can tell (I would love feedback from someone who actually knows!) bbp_code_trick() adds support for backtics representing code tags, and converts these into <code>/<pre> tags. (This explains why this part has no effect: by the time bbp_code_trick() sees the content, the user entered MD has been converted to HTML, and there are typically no backtics present (though this is not necessarily the case)).
I think because of what bbp_code_trick() expects from the backtics, when this is reversed, it results in corrupted MarkDown. And hence the issue.
Adding the following (though this would need to be done conditionally):
remove_filter( 'bbp_new_reply_pre_content', 'bbp_code_trick', 20 );
remove_filter( 'bbp_new_topic_pre_content', 'bbp_code_trick', 20 );
remove_filter( 'bbp_edit_reply_pre_content', 'bbp_code_trick', 20 );
remove_filter( 'bbp_edit_topic_pre_content', 'bbp_code_trick', 20 );
remove_filter( 'bbp_get_form_topic_content', 'bbp_code_trick_reverse', 10 );
remove_filter( 'bbp_get_form_reply_content', 'bbp_code_trick_reverse', 10 );
Fixes the issue.
Question: Am I breaking anything here with bbPress?
* An issue has been reported even at this step, but as of yet I've been unable to reproduce it.