Newlines automatically added when changing category

(Mike) #1

We use the javascript snippet to embed discourse comments. When we visit a blog post for the first time, a new topic is created and the the text is extracted automatically as expected. The topic body has a layout very similar to the initial post.

Topics are created in a single category and we have to manually move them to subcategories. When we edit the header of the topic and change the category, <br> are added between every single html tags of the topic body, e.g.:


  • … ` This bug (or feature ?) inserts undesired new lines (double spacing) everywhere. Does anyone notice this strange behavior ?

(Jeff Atwood) #2

Are you sure that comes from us? I’ve never seen this. It seems more likely that the first post body snippet from the embed is being sent incorrectly?

(Mittineague) #3

My bet is it’s WordPress’ wpautop

Changes double line-breaks in the text into HTML paragraphs (<p>…</p>).

WordPress uses it to filter the content and the excerpt.

(boolean) (optional) Preserve line breaks. When set to true, any line breaks remaining after paragraph conversion are converted to HTML <br />. Line breaks within script and style sections are not affected.
Default: true

(Mike) #4

Unfortunately @Mittineague, we do not use Wordpress at all for our site but only Jekyll to generate static html files served by an nginx server… Dynamic parts of pages are handle by javascript on client side and connected to a node.js server (Restful api endpoints).

To help in our diagnostic we have published a new post on our website and let the associated topic into the default category. We can compare HTML generated before moving to the target subcategory and the HTML content of another topic after moving (check posts in our « Le Petit Webzine » section of our website). We added a CSS style to remove the <br> effect on our forum topics with:
.posts-wrapper br { display: none; }

But this will also remove newlines for topics edited manually by forum users.

The Discourse (v1.6.0.beta8 +144) Customize/Embedding config has the following parameters:

CSS selector for elements that are allowed in embeds
h2, h3, p, ul, li, ol, #mainimage

CSS selector for elements that are removed from embeds
#lpe-cookie-disclaimer, .lpe-header, .lpe-content-header, nav, .top-share-buttons, aside, .lpe-box, footer, .bottom-share-buttons, .navigate, .note-exp, #mailModal, #optInModal, #lpe-gallery, .container-slider, .slider, .slider-ovl .slick-initialized, .slick-slider, .slick-slide, .img-left, .img-right, .img-center

Any further idea?