You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The convert command for WP-CLI changes data from one type to another.
Sample use case: Markdown to Block Markup
The idea is to be able to consume a Markdown file and turn it into a HTML file, which could then be copy/pasted or otherwise imported via the CLI into the Block Editor.
Given the following best-chicken-wings-in-scotland.md file
## Scotland's Best Chicken Wings
Found in Edinburgh, you have to visit the Wingstop at Edinburgh Fountain Stop.
These are the best wings you will find around!
![An image of a crispy chicken wing being dunked into ranch dressing](https://github.com/wp-cli/ideas/assets/3792502/a0c5ee69-d2a3-4158-bedf-a31f18529089)
Converts to
<!-- wp:heading --><h2class="wp-block-heading">Scotland's Best Chicken Wings</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Found in Edinburgh, you have to visit the Wingstop at Edinburgh Fountain Stop.</p><!-- /wp:paragraph --><!-- wp:paragraph --><p>These are the best wings you will find around!</p><!-- /wp:paragraph --><!-- wp:image {"id":7,"sizeSlug":"full","linkDestination":"none"} --><figureclass="wp-block-image size-full"><imgsrc="http://development.local/wp-content/uploads/2024/06/chicken-wing.jpg" alt="An image of a crispy chicken wing being dunked into ranch dressing" class="wp-image-7"/></figure><!-- /wp:image -->
Syntax
wp post convert best-chicken-wings-in-scotland.md
Success: Converted to HTML.
Flags
--create — Create the post as a draft in this WordPress instance. --copy — Copy HTML to the clipboard. --no-follow — Add no-follow to any image tags (good for adverts)
Behind the scenes
Uploads any images found into the Media Gallery
The text was updated successfully, but these errors were encountered:
I'd say this ask falls under #119, where we're collecting ideas for all kinds of block editor related commands.
The problem is, a convert command like this is almost impossible to build. All the information about blocks and their markup only exists in JavaScript.
We might be able to hardcode something for the core blocks such as paragraph/heading/image, but that's a maintenance nightmare as we can't possibly keep up with any changes from Gutenberg.
Description
The
convert
command forWP-CLI
changes data from one type to another.Sample use case:
Markdown
toBlock Markup
The idea is to be able to consume a
Markdown
file and turn it into aHTML
file, which could then be copy/pasted or otherwise imported via the CLI into the Block Editor.Given the following
best-chicken-wings-in-scotland.md
fileConverts to
Syntax
wp post convert best-chicken-wings-in-scotland.md
Flags
--create
— Create the post as a draft in this WordPress instance.--copy
— CopyHTML
to the clipboard.--no-follow
— Addno-follow
to any image tags (good for adverts)Behind the scenes
Uploads any images found into the
Media Gallery
The text was updated successfully, but these errors were encountered: