Convert WordPress plugin readme to Markdown

The readme.txt of a WordPress plugin needs to be formatted in a specific way, as shown in the example readme. Parts of that are already Markdown formatting, but, for example, the headlines are formatted differently. In this post, I show you a tool which converts the WordPress readme format into valid Markdown.

If I copy the readme.txt content into a readme.md, it looks like it could be optimized a bit (the screenshot is from GitHub):

The readme.txt format of WordPress in a Markdown file. (Screenshot: GitHub)

The headlines are not highlighted, and the plugin headers are in one line (okay, the latter could be fixed by just adding two spaces after each header).

Luckily, there is a project called WP Readme to Markdown – a converter that correctly formats the headlines, plugin headers, and inserts screenshots. There is also a CLI version, that can be run after changing the readme.txt easily – theoretically automatic of course, for example via an NPM script with watcher plugin.

But I did not want to through NPM or similar on my plugin, just to get this ability, so I run the command by hand. After installing the CLI via Composer, you go the to vendor/bin directory in the console and run the following command:

wp2md -i ../../readme.txt -o ../../README.md

That converts the readme.txt from the root directory of the project into a README.md. The result looks like that:

Nicely formatted: the Markdown file with the converted content of a WordPress readme. (Screenshot: GitHub)

If someone has an idea, how to get this automated with nothing but Composer and Git, let me know 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)