Skip to content

Fix formatting issues from WordPress' Classic Editor - #81

Merged
duncanmcclean merged 6 commits into
mainfrom
wp-classic-editor
Jan 9, 2025
Merged

duncanmcclean merged 6 commits into
mainfrom
wp-classic-editor

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request attempts to fix text formatting issues for conent imported from WordPress' Classic Editor.

It doesn't seem like the Classic Editor saves <p> tags when a post's content are saved in the database. Here's an example:

Non ad deserunt ea consectetur elit eu eiusmod commodo culpa ex labore incididunt culpa veniam voluptate. U<strong>llamco est excepteur laborum pariatur non aliqua qui eu labore sunt. Laborum elit dolore laboris eu enim ut. Ullamco exercitation et reprehenderit elit eiusmod officia pariatur ipsum elit. Consectetur veniam irure nostrud nisi eiusmod est Lorem voluptate aute officia occaecat eu. Cillum deserunt consequat fugiat sint velit. Quis magna elit incididunt excepteur do laboris. Ullamco laborum d</strong>olore Lorem fugiat cillum consectetur dolore laborum dolor aute culpa consequat proident.
<h2>Testing</h2>
Veniam nulla cillum esse dolor et eiusmod eu pariatur et ex qui dolore consequat occaecat amet. Exercitation occaecat ea sit id amet cupidatat sint veniam mollit velit sunt culpa. Do esse aliquip elit aute. Duis consectetur consectetur minim exercitation quis do enim consectetur quis laboris cillum ex c<a href="https://statamic.com">ulpa eu. Ipsum consequat commodo reprehenderit velit aliqua officia commodo voluptate Lorem duis cillum culpa incididunt ea laboris. Sunt veniam ipsum minim cupidatat. Labore cillum voluptate voluptate</a> mollit ad. Sit nulla ea esse mollit excepteur et voluptate cupidatat reprehenderit velit non minim Lorem.

However, when content is displayed on the frontend, it gets passed through WordPress' wpautop function which essentially runs the content through various regexes before outputting HTML to the browser.

However, since the content doesn't get passed through wpautop during an export, we end up with the unnormalized "string" which breaks TipTap (the library behind Bard).

In order to workaround this, we've added a config option which'll run your content through wpautop before transforming it into the right format for Bard.

Fixes #62.
Replaces #65.

@duncanmcclean
duncanmcclean merged commit 9db5321 into main Jan 9, 2025
@duncanmcclean
duncanmcclean deleted the wp-classic-editor branch January 9, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bard Import Issue with HTML Content from CSV

1 participant