Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

dprint-plugin-svg

A dprint Wasm plugin for formatting SVG files.

Install

dprint add kjanat/svg

Quick start

Add plugin-level options under the "svg" key in your dprint config:

{
  "svg": {
    "attributeSort": "canonical",
    "attributeLayout": "auto",
    "spaceBeforeSelfClose": true
  },
  "plugins": [
    "https://plugins.dprint.dev/kjanat/svg-v0.4.1.wasm"
  ]
}

Top-level config inheritance

Several options fall back to the top-level keys in the same dprint.json (not the user-profile “global” config — those are the per-file root keys dprint passes to every plugin). When omitted from the svg section:

Plugin optionFalls back to top-level
lineWidthlineWidth (default 100)
useTabsuseTabs (default false)
indentWidthindentWidth (default 2)
newLineKindnewLineKind (default "auto")

Plugin-owned defaults

Every other option resolves from svg_format::FormatOptions::default() via the plugin’s config-enum mappers. The table below is generated from the live schema on every mdbook build; values shown are whatever the current source ships.

OptionTypeDefault
attributeLayout"auto" | "single-line" | "multi-line""auto"
attributeSort"none" | "canonical" | "alphabetical""canonical"
attributesPerLineinteger1
blankLines"remove" | "preserve" | "truncate" | "insert""truncate"
formatEmbeddedContentbooleantrue
indentWidthintegertop-level
lineWidthintegertop-level
maxInlineTagWidthintegertop-level
newLineKind"auto" | "lf" | "crlf"top-level
quoteStyle"preserve" | "double" | "single""preserve"
spaceBeforeSelfClosebooleantrue
textContent"collapse" | "maintain" | "prettify""maintain"
useTabsbooleantop-level
wrappedAttributeIndent"one-level" | "align-to-tag-name""align-to-tag-name"

Configuration reference

Browse the sidebar for per-option documentation with before/after examples.