stephenharris / WP-MarkDown

WP-MarkDown plug-in. Allows Markdown to be enabled in posts, comments and bbPress forums.
http://wordpress.org/extend/plugins/wp-markdown/
112 stars 19 forks source link

bbPress errors submitting a topic or reply results in slashes being added to textarea content #51

Open einkoro opened 10 years ago

einkoro commented 10 years ago

For example, if you try and post a new topic and leave the title blank with the following content:

![enter image description here][1]

  [1]: http://example.org/test.png

The post will be rejected due to not having a title and then the content in the textarea becomes:

!\[enter image description here\]\[1\] [1]: http://example.org/test.png

It looks like this happens due to wpmarkdown_html_to_markdown() being called and then $md->parseString( $html ) being run on the markdown.

Adding the following check for errors fixes it for me:

function wpmarkdown_html_to_markdown( $html, $balance_tags = true ){
    if ( bbp_has_errors() )
        return $html;
    ...
einkoro commented 10 years ago

Looks like GitHub is eating the markdown in the code ticks. If you click the image button in the editor and enter http://example.org/test.png you will get the content I was entering as a test.

stephenharris commented 10 years ago

I'd rather keep any globals outside wpmarkdown_html_to_markdown() - particularly since it can be used in a context when bbPress isn't even installed.

Is there a way we can ensure wpmarkdown_html_to_markdown() isn't even called in case of errors?

einkoro commented 10 years ago

Should be able to move it up to the functions which are calling it. Probably should be using is_bbpress or checking if the plugin is loaded as well before checking for the error. I need to setup a new staging environment before testing it though as the website has been pushed live now.

On Jun 5, 2014, at 4:23, Stephen Harris notifications@github.com wrote:

I'd rather keep any globals outside wpmarkdown_html_to_markdown() - particularly since it can be used in a context when bbPress isn't even installed.

Is there a way we can ensure wpmarkdown_html_to_markdown() isn't even called in case of errors?

— Reply to this email directly or view it on GitHub.