Formatting the WP excerpt for Discourse

AI-generated summary

The discussion addresses an issue where the Discourse-WP plugin strips line breaks from WordPress excerpts. HAWK reported that posts appear without formatting, contrasting this with other installations. Mittineague suggested the root cause is wpautop converting newlines to <p> tags, which Discourse then removes. simon proposed a solution: manually creating an excerpt in WordPress preserves its formatting, whereas relying on the plugin to generate it strips everything. HAWK confirmed this manual method fixed the issue.

We use the Discourse-WP plugin and currently the {excerpt} is being displayed with no line breaks.

Here is an example:
WP Building Skills Of An Online Community Team | FeverBee
Discourse https://experts.feverbee.com/t/building-skills-of-an-online-community-team/4915

This doesn’t seem to be the case in other installs that I’ve seen.

Does anyone know of a fix?

I don’t know the fix, but it sounds like wpautop (WordPress automatic p tags) is involved.

For example, a post is entered with 2 newlines to separate paragraphs.
Instead of 2 <br> tags, (which granted, is not semantic), wpautop converts them to <p> tags while removing whitespace characters in the process.
Discourse removes the <p> tags.

Maybe disable wpautop on the WordPress side, or whitellst p tags Discourse side?

If you manually create an excerpt for the post, the formatting of that excerpt will be retained.

If, instead, you let the wp-discourse plugin create an excerpt for you, all formatting will be stripped. Possibly this is something that should be fixed.

That did the trick thanks!