Skip to content

Commit

Permalink
chore: add optional schema prop to plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco committed Jan 25, 2024
1 parent 10e5e5e commit 520e64b
Show file tree
Hide file tree
Showing 84 changed files with 1,834 additions and 1,150 deletions.
5 changes: 0 additions & 5 deletions docs/03-plugins/add-attributes-to-svg-elements.mdx
Expand Up @@ -2,11 +2,6 @@
title: Add Attributes to Elements
svgo:
pluginId: addAttributesToSVGElement
parameters:
attributes:
description: Attributes to add to the <code>&lt;svg&gt;</code> element. If key/value pairs are passed, the attributes and added with the paired value. If an array is passed, attributes are added with no key associated with them.
default: null
attribute:
---

Adds attributes to the outer most [`<svg>`](https://developer.mozilla.org/docs/Web/SVG/Element/svg) element in the document. This is not an optimization and will increase the size of SVG documents.
Expand Down
6 changes: 0 additions & 6 deletions docs/03-plugins/add-classes-to-svg-element.mdx
Expand Up @@ -2,12 +2,6 @@
title: Add Classes to SVG
svgo:
pluginId: addClassesToSVGElement
parameters:
classNames:
description: Adds the specified class names to the outer most <code>&lt;svg&gt;</code> element.
default: null
className:
description: Adds the specified class name to the outer most <code>&lt;svg&gt;</code> element. If <code>classNames</code> is specified, this is ignored.
---

Overrides the `class` attribute in the outer most `<svg>` element, omitting duplicates or null classes if found in your configuration.
Expand Down
13 changes: 0 additions & 13 deletions docs/03-plugins/cleanup-attrs.mdx
Expand Up @@ -3,19 +3,6 @@ title: Cleanup Attributes
svgo:
pluginId: cleanupAttrs
defaultPlugin: true
parameters:
newlines:
description: Replace instances of a newline with a single whitespace.
type: boolean
default: true
trim:
description: Trim whitespace characters from the start and end of attribute values.
type: boolean
default: true
spaces:
description: Replace all instances of 2 or more whitespace characters with a single whitespace.
type: boolean
default: true
---

Removes redundant whitespaces from attribute values.
Expand Down
16 changes: 0 additions & 16 deletions docs/03-plugins/cleanup-ids.mdx
Expand Up @@ -2,22 +2,6 @@
title: Cleanup IDs
svgo:
pluginId: cleanupIds
parameters:
remove:
description: If to remove all unreferenced IDs.
default: true
minify:
description: If to minify referenced IDs.
default: true
preserve:
description: Elements with one of these IDs will be ignored.
default: []
preservePrefixes:
description: Elements with an ID that starts with one of these prefixes will be ignored.
default: []
force:
description: This plugin normally does nothing if a <code>&lt;script&gt;</code> or <code>&lt;style&gt;</code> element is found. Setting this to true will bypass that behaviour, which may result in destructive changes.
default: false
defaultPlugin: true
---

Expand Down
13 changes: 0 additions & 13 deletions docs/03-plugins/cleanup-list-of-values.mdx
Expand Up @@ -2,19 +2,6 @@
title: Cleanup List of Values
svgo:
pluginId: cleanupListOfValues
parameters:
floatPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: 3
leadingZero:
description: If to trim leading zeros.
default: true
defaultPx:
description: If to remove the units when it's <code>px</code>, as this is the default if not specified.
default: true
convertToPx:
description: If to convert absolute units like <code>cm</code> and <code>in</code> to <code>px</code>.
default: true
---

# Cleanup List of Values
Expand Down
13 changes: 0 additions & 13 deletions docs/03-plugins/cleanup-numeric-values.mdx
Expand Up @@ -3,19 +3,6 @@ title: Cleanup Numeric Values
svgo:
pluginId: cleanupNumericValues
defaultPlugin: true
parameters:
floatPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: 3
leadingZero:
description: If to trim leading zeros.
default: true
defaultPx:
description: If to remove the units when it's <code>px</code>, as this is the default if not specified.
default: true
convertToPx:
description: If to convert absolute units like <code>cm</code> and <code>in</code> to <code>px</code>.
default: true
---

Rounds numeric values, and removes the unit when it's `px` as this is the default.
Expand Down
19 changes: 0 additions & 19 deletions docs/03-plugins/convert-colors.mdx
Expand Up @@ -3,25 +3,6 @@ title: Convert Colors
svgo:
pluginId: convertColors
defaultPlugin: true
parameters:
currentColor:
description: If to convert all instances of a color to <code>currentcolor</code>. This means to inherit the active foreground color, for example in HTML5 this would be the <a href="https://developer.mozilla.org/docs/Web/CSS/color" target="_blank"><code>color</code></a> property in CSS.
default: false
names2hex:
description: If to convert color names to the hex equivalent.
default: true
rgb2hex:
description: If to convert RGB colors to the hex equivalent, ignores RGBA.
default: true
convertCase:
description: Convert all color values to either upper or lower case by setting this to <code>'upper'</code> or <code>'lower'</code> respectively to improve compression. Set to <code>false</code> to disable this behavior.
default: 'lower'
shorthex:
description: If to convert 6 character hex colors to the 3 character equivalent where possible.
default: true
shortname:
description: If to convert hex colors to the color name, if the color name is shorter then the hex equivalent.
default: true
---

Converts color references to the shortest equivalent.
Expand Down
47 changes: 0 additions & 47 deletions docs/03-plugins/convert-path-data.mdx
Expand Up @@ -3,53 +3,6 @@ title: Convert Path Commands
svgo:
pluginId: convertPathData
defaultPlugin: true
parameters:
applyTransforms:
description: If to apply transforms.
default: true
applyTransformsStroked:
description: If to apply transforms to paths with a stroke.
default: true
makeArcs:
description: If to convert from curves to arcs when possible. This is an object with two properties, <code>threshold</code> and <code>tolerance</code>.
straightCurves:
description: If to convert curve commands that are effectively straight lines to line commands.
default: true
convertToQ:
description: If to convert cubic beziers to quadratic beziers when they effectively are.
default: true
lineShorthands:
description: If to convert regular lines to an explicit horizontal or vertical line where possible.
default: true
convertToZ:
description: If to convert lines that go to the start to a <code>z</code> command.
default: true
curveSmoothShorthands:
description: If to convert curves to smooth curves where possible.
default: true
floatPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: 3
transformPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: 5
smartArcRounding:
description: Round the radius of circular arcs when the effective change is under the error. The effective change is determined using the <a href="https://wikipedia.org/wiki/Sagitta_(geometry)" target="_blank">sagitta</a> of the arc.
default: true
removeUseless:
description: Remove redundant path commands that don't draw anything.
default: true
collapseRepeated:
description: Collapse repeated commands when they can be merged into one.
default: true
utilizeAbsolute:
description: If to convert between absolute or relative coordinates, whichever is shortest.
default: true
negativeExtraSpace:
default: true
forceAbsolutePath:
description: If to always convert to absolute coordinates, even if it adds more bytes.
default: false
---

Optimize path commands found in `<path>`, `<glyph>`, and `<missing-glyph>` elements. Path commands are the syntax used in the `d` attribute, each character represents an instruction to draw paths.
Expand Down
7 changes: 0 additions & 7 deletions docs/03-plugins/convert-shape-to-path.mdx
Expand Up @@ -3,13 +3,6 @@ title: Convert Shape to Path
svgo:
pluginId: convertShapeToPath
defaultPlugin: true
parameters:
convertArcs:
description: If to convert <code>&lt;circle&gt;</code> and <code>&lt;ellipse&gt;</code> elements to paths.
default: false
floatPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: null
---

Convert basic shapes to [`<path>`](https://developer.mozilla.org/docs/Web/SVG/Element/path) elements.
Expand Down
5 changes: 0 additions & 5 deletions docs/03-plugins/convert-style-to-attrs.mdx
Expand Up @@ -2,11 +2,6 @@
title: Convert Style to Attributes
svgo:
pluginId: convertStyleToAttrs
parameters:
keepImportant:
description: If to always keep <a href="https://developer.mozilla.org/docs/Web/CSS/important" target="_blank"><code>!important</code></a> styles.
type: boolean
default: false
---

Converts [presentation attributes](https://developer.mozilla.org/docs/Web/SVG/Attribute/Presentation) in element styles to the equvilent XML attribute.
Expand Down
30 changes: 0 additions & 30 deletions docs/03-plugins/convert-transform.mdx
Expand Up @@ -3,36 +3,6 @@ title: Convert Transform
svgo:
pluginId: convertTransform
defaultPlugin: true
parameters:
convertToShorts:
description: Convert transforms to their shorthand alternatives.
default: true
degPrecision:
description: Number of decimal places to round degrees values to, using conventional rounding rules. Used for <code>rotate</code> and <code>skew</code>.
floatPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: 3
transformPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: 5
matrixToTransform:
description: If decompose matrices into simple transforms. See <a href="https://frederic-wang.fr/decomposition-of-2d-transform-matrices.html" target="_blank">Decomposition of 2D-transform matrices</a> for more context.
default: true
shortTranslate:
description: If to shorten references to <code>translate</code> with redundant parameters to omit them. i.e. <code>translate(10 0)</code> → <code>translate(10)</code>
default: true
shortScale:
description: If to shorten references to <code>scale</code> with redundant parameters to omit them. i.e. <code>scale(2 2)</code> → <code>scale(2)</code>
default: true
shortRotate:
description: If to shorten references to <code>rotate</code> with redundant parameters to omit them. i.e. <code>translate(cx cy) rotate(a) translate(-cx -cy)</code> → <code>rotate(a cx cy)</code>
default: true
removeUseless:
description: If to remove redundant transforms like <code>translate(0)</code>, <code>skewX(0)</code>, or <code>skewY(0)</code>.
default: true
collapseIntoOne:
description: If to multiply transforms into one.
default: true
---

Collapse multiple transforms into one, convert matrices to the short aliases, and much more.
Expand Down
11 changes: 0 additions & 11 deletions docs/03-plugins/inline-styles.mdx
Expand Up @@ -3,17 +3,6 @@ title: Inline Styles
svgo:
pluginId: inlineStyles
defaultPlugin: true
parameters:
onlyMatchedOnce:
description: If to only inline styles if the selector matches one element.
default: true
removeMatchedSelectors:
description: If to remove the selector and styles from the stylesheet while inlining the styles. This does not remove selectors that did not match any elements.
default: true
useMqs:
description: An array of media query conditions to use, such as <code>screen</code>. An empty string signifies all selectors outside of a media query.
usePseudos:
description: What pseudo-classes and pseudo-elements to use. An empty string signifies all non-pseudo-classes and non-pseudo-elements.
---

Merges styles from `<style>` elements to the `style` attribute of matching elements.
Expand Down
9 changes: 0 additions & 9 deletions docs/03-plugins/merge-paths.mdx
Expand Up @@ -3,15 +3,6 @@ title: Merge Paths
svgo:
pluginId: mergePaths
defaultPlugin: true
parameters:
force:
default: false
floatPrecision:
description: Number of decimal places to round to, using conventional rounding rules.
default: null
noSpaceAfterFlags:
description: If to omit spaces after flags. Flags are values that can only be <code>0</code> or <code>1</code> and are used by some path commands, namely <a href="https://developer.mozilla.org/docs/Web/SVG/Attribute/d#elliptical_arc_curve" target="_blank"><code>A</code> and <code>a</code></a>.
default: false
---

Merge multiple paths into one.
Expand Down
4 changes: 0 additions & 4 deletions docs/03-plugins/minify-styles.mdx
Expand Up @@ -3,10 +3,6 @@ title: Minify Styles
svgo:
pluginId: minifyStyles
defaultPlugin: true
parameters:
usage:
description: If to collect usage data such as tags, classes, and IDs to pass to CSSO. This is an object with four properties, which are each configured with a boolean, <code>tags</code>, <code>ids</code>, <code>classes</code>, and <code>force</code>. By default, if a script is found this does not pass usage data to CSSO, but this can be overridden with <code>force</code>, which may yield destructive changes.
default: true
---

Minify `<style>` elements with [CSSO](https://github.com/css/csso).
Expand Down
12 changes: 0 additions & 12 deletions docs/03-plugins/prefix-ids.mdx
Expand Up @@ -2,18 +2,6 @@
title: Prefix IDs
svgo:
pluginId: prefixIds
parameters:
delim:
description: Content to insert between the prefix and original value.
default: '__'
prefix:
description: Either a string or a function that resolves to a string.
prefixIds:
description: If to prefix <code>id</code> attributes.
default: true
prefixClassNames:
description: If to prefix classes in the <code>class</code> attribute.
default: true
---

Prefix element IDs and class names with the filename or another arbitrary string.
Expand Down
4 changes: 0 additions & 4 deletions docs/03-plugins/remove-attributes-by-selector.mdx
Expand Up @@ -2,10 +2,6 @@
title: Remove Attributes by Selector
svgo:
pluginId: removeAttributesBySelector
parameters:
selectors:
description: An array of objects with two properties, <code>selector</code>, and <code>attributes</code>, which represent a CSS selector and the attributes to remove respectively.
default: null
---

Removes specific attributes from elements that match a CSS selector.
Expand Down
10 changes: 0 additions & 10 deletions docs/03-plugins/remove-attrs.mdx
Expand Up @@ -2,16 +2,6 @@
title: Remove Attributes
svgo:
pluginId: removeAttrs
parameters:
attrs:
description: A selector that matches attributes.
default: null
elemSeparator:
description: The pattern syntax used by this plugin is <code>element:attribute:value</code>, this changes the delimiter from <code>:</code> to another string.
default: ':'
preserveCurrentColor:
description: If to ignore the attribute when it's set to <code>currentcolor</code>.
default: false
---

Remove attributes from elements matching a custom syntax.
Expand Down
5 changes: 0 additions & 5 deletions docs/03-plugins/remove-comments.mdx
Expand Up @@ -3,11 +3,6 @@ title: Remove Comments
svgo:
pluginId: removeComments
defaultPlugin: true
parameters:
preservePatterns:
description: An array of regular expressions (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp" target="_blank">RegExp</a> or string). If the comment matches any of these, including partial matches, the comment is preserved. Set to <code>false</code> to disable this behavior and remove comments indiscriminately.
default:
- '^!'
---

Removes XML comments from the document.
Expand Down
5 changes: 0 additions & 5 deletions docs/03-plugins/remove-deprecated-attrs.mdx
Expand Up @@ -3,11 +3,6 @@ title: Remove Deprecated Attributes
svgo:
pluginId: removeDeprecatedAttrs
defaultPlugin: true
parameters:
removeAny:
description: By default, this plugin only removes safe deprecated attributes that do not change the rendered image. Enabling this will remove all deprecated attributes which may impact rendering.
type: boolean
default: false
---

Removes deprecated attributes from elements in the document.
Expand Down
5 changes: 0 additions & 5 deletions docs/03-plugins/remove-desc.mdx
Expand Up @@ -3,11 +3,6 @@ title: Remove Description
svgo:
pluginId: removeDesc
defaultPlugin: true
parameters:
removeAny:
description: By default, this plugin only removes descriptions that are either empty or contain editor attribution. Enabling this removes the <code>&lt;desc&gt;</code> element indiscriminately.
type: boolean
default: false
---

Removes the [`<desc>`](https://developer.mozilla.org/docs/Web/SVG/Element/desc) element from the document in one of the following conditions:
Expand Down
4 changes: 0 additions & 4 deletions docs/03-plugins/remove-editors-ns-data.mdx
Expand Up @@ -3,10 +3,6 @@ title: Remove Editor Namespace Data
svgo:
pluginId: removeEditorsNSData
defaultPlugin: true
parameters:
additionalNamespaces:
description: If you want to remove additional XML namespaces, you can provide them in a list.
default: []
---

Removes all XML [namespaces](https://developer.mozilla.org/docs/Web/SVG/Namespaces_Crash_Course), elements, and attributes associated with popular vector editing software.
Expand Down

0 comments on commit 520e64b

Please sign in to comment.