wp-cli / ideas

💡 Ideas and feature requests are collected here
40 stars 1 forks source link

Import/export of posts in Markdown format #196

Open vadimkantorov opened 6 days ago

vadimkantorov commented 6 days ago

Of course, markdown is much more restricted than general block markup, but for many blogs having some basic support would be very nice (especially for CLI-oriented people starting to play with WordPress with existing Markdown files), as there are plenty of various Markdown editors, and many simple blogs are written in the Markdown format (with some html tags sprinkled). It is okay if this support is not perfect as not every block can be faitfully and completely represented by some markdown/with minimal html tags/styles

WordPress has a ton of many different Markdown plugins, but having some basic variant (relying on some existing established php Markdown library) in the wp-cli (and thus having a smaller scope) would simplify simple blogs workflow and interop of WordPress with other blog engines.

This would be very helpful for usage of WordPress as static site generator.

swissspidy commented 6 days ago

This sounds like a good use case for a community-maintained package. https://github.com/gloomic/wp-cli-markdown-post seems to be doing parts of what you're looking for, maybe that can serve as a foundation.

vadimkantorov commented 2 days ago

Yeah, I found that in WP ecosystem there're many-many various markdown plugins taking various approaches wrt rendering and editing (either render markdown2html at post adding time or keep the original markdown).

My usecase is: importing markdown posts to be able to use WP as a static-site-generator (meaning that I don't have a maintained WP instance, I'm reinitializing the database from scratch at every site build. I'm keeping wp_options as a JSON file and all posts as files in a github repo and I'm importing them at site build). So for this usecase rendering the posts to html at import time is totally okay, and what's important is keeping compat with Jekyll post filename format and the Jekyll frontmatter fields (like title, authors, tags). I currently somewhat managed to do this using https://github.com/dirtsimple/postmark, but it doesn't support very well Jekyll's frontmatter...

https://github.com/gloomic/wp-cli-markdown-post seems also possible, but its installation seems to require modification of theme files.

I realize that maybe this usecase is not the main usecase for WP, but maybe having some very basic support for Markdown in core WP/wp-cli would be nice. I am of course not blocked, just it's a bit hard to figure out which plugins to use. So if this usecase of using WP as static-site-generator is considered important (thus needed kind of tested wp-cli commands to import options, add posts from markdown files and static rendering of the whole site), maybe some recipe / instruction of using some plugins to achieve this would be very helpful. But I also understand why you might not actually want that.