Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP-CLI Command: convert #187

Open
flexseth opened this issue Jun 4, 2024 · 1 comment
Open

WP-CLI Command: convert #187

flexseth opened this issue Jun 4, 2024 · 1 comment

Comments

@flexseth
Copy link

flexseth commented Jun 4, 2024

Description

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 -->
<h2 class="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"} -->
<figure class="wp-block-image size-full"><img src="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

@swissspidy
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants