Skip to content

co6x0/prettier-plugin-wp-block-html

Repository files navigation

prettier-plugin-wp-block-html

A Prettier plugin for HTML in WordPress Block Theme.

This plugin formats unique HTML code including Block markups in the WordPress block theme.

⚠️ Warning

This plugin is currently in beta. It may return unexpected results.

Usage

In most cases, you can just install prettier-plugin-wp-block-html and start using it. The plugin will work automatically after installation.

npm install -D prettier prettier-plugin-wp-block-html

If the plugin cannot be found automatically, you can load it as follows:

// prettier.config.js
module.exports = {
  plugins: ["prettier-plugin-wp-block-html"],
};

Alternatively:

npx prettier --write ./parts/header.html --plugin prettier-plugin-wp-block-html

For more information, please refer to Prettier documentation.

Using with other Prettier plugins

This plugin uses specific Prettier APIs, which may conflict with other plugins that use similar APIs.

To avoid this problem, consider the order of the plugins in the Prettier configuration file. Now you can use this plugin with prettier-plugin-tailwindcss.

// .prettierrc.json
{
  "plugins": ["prettier-plugin-tailwindcss", "prettier-plugin-wp-block-html"]
}