markup_fmt is a configurable HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks, Vento, Mustache, Handlebars and XML formatter.
- Support for Django templates in 2d418d6
- Support configuring a list of custom blocks with
--custom-blocks "markdown,flatblock"in b73a519 - Converge in one pass when formatting a style attr with malva in 05b33f0 (See upstream PR)
- expose ast and parser modules
- Don't format django multiline comment tags (
{% comment %}...{% endcomment %}) in 16417e7 - Fix indent of
{% for %}/{% empty %}blocks - Fix formatting of some intermediate tags like
{% plural %}inside{% blocktranslate %} - Add a
preserveUnquotedAttrsoption to support django-cotton
This formatter provides some options such as vBindStyle, vOnStyle and more for Vue and
svelteAttrShorthand and svelteDirectiveShorthand for Svelte.
It's recommended to enable these options in this formatter and disable the corresponding rules in eslint-plugin-vue and eslint-plugin-svelte if you used. This will make ESLint faster because less rules will be executed.
We've provided dprint integration.
This plugin only formats HTML syntax of your HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks, Vento, Mustache, Handlebars and XML files.
You also need other dprint plugins to format the code in <script> and <style> tags.
You can use dprint-plugin-typescript to
format TypeScript/JavaScript code and Malva to format CSS/SCSS/Sass/Less code.
Run the commands below to add plugins:
dprint config add g-plane/markup_fmt
dprint config add g-plane/malva
dprint config add typescriptIf you also want to format JSON in <script> tag whose "type" is "importmap", "application/json", or "application/ld+json",
you can add dprint-plugin-json:
dprint config add jsonIf you want to format Jinja, it's recommended to add Pretty Jinja dprint plugin as well.
After adding the dprint plugins, update your dprint.json and add configuration:
You can also read dprint CLI documentation for using dprint to format files.
Please read the documentation.
Please refer to Configuration.
Tests come from:
MIT License
Copyright (c) 2023-present Pig Fang
{ // ... "plugins": [ // ... other plugins URL "https://plugins.dprint.dev/g-plane/markup_fmt-v0.27.0.wasm" ], "markup": { // <-- the key name here is "markup", not "markup_fmt" // config comes here } }