rainlab / blog-plugin

A robust blogging platform.
MIT License
169 stars 143 forks source link

Only the first HTML tag of the Richeditor content gets displayed in the front end #588

Closed grwllrnc closed 1 month ago

grwllrnc commented 2 months ago

Hi there,

We are using Rainlab’s blog plugin v1.7 with October 3.5.15 resp. 3.6.30 and the ‘Force the WYSIWYG editor’ option activated in the settings.

While writing new blog posts we encountered the problem that only the first HTML tag of the Richeditor content gets displayed in the front end. The rest of the content is chopped off.

A look in the database table rainlab_blog_posts shows, that the field content contains the entire HTML content inserted in the backend. While the field content_html contains only the first HTML tag of the content field.

The model Post.php is parsing the content with Markdown::parse() before inserting the result into the database field content_html.

Apparently, the markdown parser chops off the content after the first HTML tag.

If I hand over the Richeditor content without the Markdown::parse() in line 213, like this

        // $result = Markdown::parse(trim($input));
        $result = $input;

it gets displayed correctly.

Or if I wrap the Richeditor content in line 142 in a single div tag like this

        $this->content_html = self::formatHtml('<div>' . $this->content . '</div>');

or manually in the Richeditor source view it self, the content gets displayed correctly too.

Our Richeditor wraps every thing into <p> tags except for some excluded tags, and these <p> tags do not have parents only siblings.

Is this a bug? Or is our integration not correct?

Thanks in advance for your reply.

Micolithe commented 2 months ago

I'm also facing this issue.

I'd like to thank the OP for pointing out that I can get around it by using the blogPost.post.content field, I was tearing my hair out trying to figure out why it was only returning the first <p> tag's contents. I will do this as a workaround until the content_html tag is fixed.

daftspunk commented 1 month ago

Fixed in e635f52d2b389bf6b9bcc2e5711bf399614f5a09