Options name in this page are in camel case. If you're using markup_fmt as a Rust crate, please use snake case instead.
The line width limitation that markup_fmt should (but not must) avoid exceeding. markup_fmt will try its best to keep line width less than this value, but it may exceed for some cases, for example, a very very long single word.
Default option is 80
.
<script src="very-very-very-very-long-name.js" async defer></script>
<script
src="very-very-very-very-long-name.js"
async
defer
></script>
Specify use space or tab for indentation.
Default option is false
.
Size of indentation. When enabled useTabs
, this option may be disregarded,
since only one tab will be inserted when indented once.
Default option is 2
. This can't be zero.
<script
src="very-very-very-very-long-name.js"
async
defer
></script>
<script
src="very-very-very-very-long-name.js"
async
defer
></script>
Specify whether use \n
(LF) or \r\n
(CRLF) for line break.
Default option is "lf"
. Possible options are "lf"
and "crlf"
.
Control the quotes of attribute value.
Possible options:
"double"
: Use double quotes as possible. However if there're double quotes in strings, quotes will be kept as-is."single"
: Use single quotes as possible. However if there're single quotes in strings, quotes will be kept as-is.
Default option is "double"
.
<div class=""></div>
<div class=''></div>
Control whether whitespace should be inserted at the beginning and end of comments and comments should be indented properly or not.
When this option is set to false
, comments contain leading or trailing whitespace will still be kept as-is.
Default option is false
.
<!--comments-->
<!--very very very very very very very very very very very very very very very very long-->
<!-- comments -->
<!--
very very very very very very very very very very very very very very very very long
-->
Control whether the code block in the <script>
tag should be indented or not.
Default option is false
.
This global option can be overridden for individual languages by the following options:
html.scriptIndent
vue.scriptIndent
svelte.scriptIndent
astro.scriptIndent
<script>
const a = 0
</script>
<script>
const a = 0
</script>
Control whether the code block in the <style>
tag should be indented or not.
Default option is false
.
This global option can be overridden for individual languages by the following options:
html.styleIndent
vue.styleIndent
svelte.styleIndent
astro.styleIndent
<style>
a { outline: none; }
</style>
<style>
a { outline: none; }
</style>
Control the closing bracket (>
) of a multi-line element should come at the end of the last line
or on the next line (with a line break).
Default option is false
.
<span
class=""
style=""
></span>
<span
class=""
style=""></span>
When there're no children in an element, this option controls whether to insert a line break before the closing tag or not.
Possible options:
"always"
: Always insert a line break before the closing tag."fit"
: Only insert a line break if it doesn't fit theprintWidth
option."never"
: Don't insert a line break.
Default option is "fit"
.
<div>
</div>
<div class="very-very-very-very-very-very-very-very-very-long-class-name">
</div>
<div></div>
<div class="very-very-very-very-very-very-very-very-very-long-class-name">
</div>
<div></div>
<div class="very-very-very-very-very-very-very-very-very-long-class-name"></div>
Control the maximum number of attributes in one line. If this option is unset, there won't be any limitations.
This option conflicts with preferAttrsSingleLine
option.
Default option is null
. This option can't be 0
.
<div data-a data-b data-c></div>
<div
data-a
data-b
data-c
></div>
<div
data-a data-b
data-c
></div>
Control whether attributes should be put on single line when possible.
This option conflicts with maxAttrsPerLine
option.
Default option is false
.
This <div>
is short enough to be put on single line,
but it won't because attributes in source code span multiple lines.
<div
data-a
data-b
></div>
This <div>
is short enough so it will be put on single line
though attributes span multiple lines in source code.
<div data-a data-b></div>
This group of options controls whether an element should be self-closed or not if it doesn't have children.
There're several options:
html.normal.selfClosing
: This option affects on HTML normal elements.html.void.selfClosing
: This option affects on HTML void elements.component.selfClosing
: This option affects on Vue/Svelte/Astro/Angular components.svg.selfClosing
: This option affects on SVG elements.mathml.selfClosing
: This option affects on MathML elements.
All of these options can be set as null
, true
or false
:
null
: Whether the element is self-closed or not won't be changed. Keep it as-is.true
: Element will always be self-closed.false
: Element will never be self-closed.
All of these options are default to null
.
Input:
<div />
<div></div>
Output:
<div />
<div></div>
Input:
<div />
<div></div>
Output:
<div />
<div />
Input:
<div />
<div></div>
Output:
<div></div>
<div></div>
Control the whitespace sensitivity before and after the children of an element. This is similar to Prettier, so you can read its blog for detail.
Possible options:
"css"
: Respect the default value of CSSdisplay
property."strict"
: Whitespace (or the lack of it) around all tags is considered significant."ignore"
: Whitespace (or the lack of it) around all tags is considered insignificant.
Default option is "css"
.
This option can be overridden for Vue/Svelte/Astro/Angular components by the following option:
component.whitespaceSensitivity
Input:
<div> text </div>
<span> text </span>
Output:
<div>text</div>
<span> text </span>
Input:
<div> text </div>
<span> text </span>
Output:
<div> text </div>
<span> text </span>
Input:
<div> text </div>
<span> text </span>
Output:
<div>text</div>
<span>text</span>
Control the case of "doctype" keyword in <!DOCTYPE>
.
Possible options:
"ignore"
: Keep the case as-is."upper"
: Print "DOCTYPE" in upper case."lower"
: Print "doctype" in lower case.
Default option is "upper"
.
Input:
<!DOCTYPE html>
<!doctype html>
Output:
<!DOCTYPE html>
<!doctype html>
Input:
<!DOCTYPE html>
<!doctype html>
Output:
<!DOCTYPE html>
<!DOCTYPE html>
Input:
<!DOCTYPE html>
<!doctype html>
Output:
<!doctype html>
<!doctype html>
Control Vue v-bind
directive style.
Possible options:
null
: Style ofv-bind
directive won't be changed."short"
: Use short-hand form like:value
."long"
: Use long-hand form likev-bind:value
.
Default option is null
.
Input:
<input :value="">
<input v-bind:value="">
Output:
<input :value="">
<input v-bind:value="">
Input:
<input :value="">
<input v-bind:value="">
Output:
<input :value="">
<input :value="">
Input:
<input :value="">
<input v-bind:value="">
Output:
<input v-bind:value="">
<input v-bind:value="">
Control Vue v-on
directive style.
Possible options:
null
: Style ofv-on
directive won't be changed."short"
: Use short-hand form like@click
."long"
: Use long-hand form likev-on:click
.
Default option is null
.
Input:
<button @click=""></button>
<button v-on:click=""></button>
Output:
<button @click=""></button>
<button v-on:click=""></button>
Input:
<button @click=""></button>
<button v-on:click=""></button>
Output:
<button @click=""></button>
<button @click=""></button>
Input:
<button @click=""></button>
<button v-on:click=""></button>
Output:
<button v-on:click=""></button>
<button v-on:click=""></button>
Control Vue v-for
directive delimiter style.
Possible options:
null
: Style ofv-for
directive delimiter won't be changed."in"
: Usein
asv-for
delimiter."of"
: Useof
asv-for
delimiter.
Default value is null
.
Input:
<li v-for="item in list"></li>
<li v-for="item of list"></li>
Output:
<li v-for="item in list"></li>
<li v-for="item of list"></li>
Input:
<li v-for="item in list"></li>
<li v-for="item of list"></li>
Output:
<li v-for="item in list"></li>
<li v-for="item in list"></li>
Input:
<li v-for="item in list"></li>
<li v-for="item of list"></li>
Output:
<li v-for="item of list"></li>
<li v-for="item of list"></li>
Control Vue v-slot
directive style.
Possible options:
null
: Style ofv-slot
directive won't be changed."short"
: Use short-hand form like#default
or#named
."long"
: Use long-hand form likev-slot:default
orv-slot:named
."vSlot"
: For default slot, usev-slot
(shorter than#default
); otherwise, use short-hand form.
Default option is null
.
This global option can be overridden by the following options:
component.vSlotStyle
: Controlv-slot
style at components.default.vSlotStyle
: Controlv-slot
style of default slot at<template>
tag.named.vSlotStyle
: Controlv-slot
style of named slot at<template>
tag.
Input:
<template v-slot:default></template>
<template v-slot:header></template>
<template #default></template>
<template #header></template>
Output:
<template v-slot:default></template>
<template v-slot:header></template>
<template #default></template>
<template #header></template>
Input:
<template v-slot:default></template>
<template v-slot:header></template>
<template #default></template>
<template #header></template>
Output:
<template #default></template>
<template #header></template>
<template #default></template>
<template #header></template>
Input:
<template v-slot:default></template>
<template v-slot:header></template>
<template #default></template>
<template #header></template>
Output:
<template v-slot:default></template>
<template v-slot:header></template>
<template v-slot:default></template>
<template v-slot:header></template>
Input:
<template v-slot:default></template>
<template v-slot:header></template>
<template #default></template>
<template #header></template>
Output:
<template v-slot></template>
<template #header></template>
<template v-slot></template>
<template #header></template>
Control whether Vue attribute should be written in short-hand form or not if attribute name and value are same. If this option is unset, attribute won't be changed.
Available since v0.3.0.
Default value is null
.
Input:
<MyComponent :value />
<MyComponent :value="value" />
Output:
<MyComponent :value />
<MyComponent :value="value" />
Input:
<MyComponent :value />
<MyComponent :value="value" />
Output:
<MyComponent :value />
<MyComponent :value />
Input:
<MyComponent :value />
<MyComponent :value="value" />
Output:
<MyComponent :value="value" />
<MyComponent :value="value" />
Control whether Svelte attribute value should be in strict mode or not.
Default option is false
.
<div class={class}></div>
<div class="{class}"></div>
Control whether Svelte attribute should be written in short-hand form or not when possible. If this option is unset, attribute won't be changed.
Default value is null
.
Input:
<MyComponent {value} />
<MyComponent value={value} />
Output:
<MyComponent {value} />
<MyComponent value={value} />
Input:
<MyComponent {value} />
<MyComponent value={value} />
Output:
<MyComponent {value} />
<MyComponent {value} />
Input:
<MyComponent {value} />
<MyComponent value={value} />
Output:
<MyComponent value={value} />
<MyComponent value={value} />
Control whether Svelte directive should be written in short-hand form or not when possible. If this option is unset, directive won't be changed.
Default value is null
.
Input:
<MyComponent bind:value />
<MyComponent bind:value={value} />
Output:
<MyComponent bind:value />
<MyComponent bind:value={value} />
Input:
<MyComponent bind:value />
<MyComponent bind:value={value} />
Output:
<MyComponent bind:value />
<MyComponent bind:value />
Input:
<MyComponent bind:value />
<MyComponent bind:value={value} />
Output:
<MyComponent bind:value={value} />
<MyComponent bind:value={value} />
Control whether Astro attribute should be written in short-hand form or not when possible. If this option is unset, attribute won't be changed.
Default value is null
.
Input:
<MyComponent {value} />
<MyComponent value={value} />
Output:
<MyComponent {value} />
<MyComponent value={value} />
Input:
<MyComponent {value} />
<MyComponent value={value} />
Output:
<MyComponent {value} />
<MyComponent {value} />
Input:
<MyComponent {value} />
<MyComponent value={value} />
Output:
<MyComponent value={value} />
<MyComponent value={value} />
Text directive for ignoring formatting specific element or node.
Default is "markup-fmt-ignore"
.
<div></div>
<!-- markup-fmt-ignore -->
<div > </div>