Skip to content

Configurable HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks and Vento formatter with dprint integration.

License

Notifications You must be signed in to change notification settings

g-plane/markup_fmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b72c15d · Feb 14, 2025
Jan 21, 2025
Oct 30, 2023
Dec 2, 2024
Feb 12, 2025
Feb 14, 2025
May 13, 2024
Oct 13, 2023
Mar 29, 2024
Aug 29, 2024
Dec 2, 2024
Oct 15, 2023
Oct 13, 2023
Dec 2, 2024

Repository files navigation

markup_fmt

markup_fmt is a configurable HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks and Vento formatter.

Notes for Vue and Svelte Users

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.

Getting Started

dprint

We've provided dprint integration.

This plugin only formats HTML syntax of your HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks and Vento 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 typescript

If 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 json

Or Biome:

- dprint config add typescript
- dprint config add json
+ dprint config add biome

After adding the dprint plugins, update your dprint.json and add configuration:

{
  // ...
  "plugins": [
    // ... other plugins URL
    "https://plugins.dprint.dev/g-plane/markup_fmt-v0.18.0.wasm"
  ],
  "markup": { // <-- the key name here is "markup", not "markup_fmt"
    // config comes here
  }
}

You can also read dprint CLI documentation for using dprint to format files.

Use as a Rust crate

Please read the documentation.

Configuration

Please refer to Configuration.

Credit

Tests come from:

License

MIT License

Copyright (c) 2023-present Pig Fang