Skip to content

Commit

Permalink
Update documentation. (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkenny54 authored Oct 10, 2024
1 parent ed5034f commit 6c18d57
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 68 deletions.
58 changes: 0 additions & 58 deletions docs/04-plugins/removeHiddenElems.mdx

This file was deleted.

2 changes: 2 additions & 0 deletions docs/plugins/cleanupStyleAttributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The `style` attribute is removed from all animation elements.

The list of allowable properties comes from https://www.w3.org/TR/SVG2/styling.html#PresentationAttributes, and also includes the `font` shorthand property.

Empty `style` attributes are removed.

Style attributes are not changed if the document has attribute selectors on the `style` attribute.

### `class` Attributes
Expand Down
24 changes: 24 additions & 0 deletions docs/plugins/createGroups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# createGroups

Creates `<g>` elements containing common properties for adjacent siblings.

## Details

The plugin has no effect if:

- The document has scripts.
- The document has `<style>` elements with CSS which **svgo-ll** is not able to process.
- The `<style>` element contains at least one rule.

Groups are only created for children of `<svg>` and `<g>` elements.

Adjacent siblings which have at least one common property are combined into a group. The following properties will be moved to the group if shared by all elements:

- Any inheritable properties.
- The `transform` and `transform-origin` properties, except that if both are present in the children, they are not moved to the group unless both can be moved.

All common properties are written to the group element as part of the `style` attribute, except for `transform`, which is written as an attribute.

The following are never put into a group:

- Elements which are referenced by a `<use>` element.
2 changes: 2 additions & 0 deletions docs/plugins/inlineStyles.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Moves style properties from `<style>` elements to the `style` attribute of matching elements.

## Details

The plugin has no effect if:

- The document has scripts.
Expand Down
27 changes: 27 additions & 0 deletions docs/plugins/removeHiddenElems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# removeHiddenElems

Removes [non-rendered elements](https://svgwg.org/svg2-draft/render.html#TermNeverRenderedElement) that are not used.

## Details

The plugin has no effect if:

- The document has scripts.
- The document has `<style>` elements with CSS which **svgo-ll** is not able to process.
- The `<style>` element has features other than simple selectors or attribute selectors.

The following elements are removed, except as specified below:

- Any children of `<defs>` which have no id.
- If a non-rendering element with no `id` attribute is encountered outside of a `<defs>`, the element is changed to a `<defs>`, and its content is processed as above.
- Empty shape elements with no id.
- Elements with `display:none`.
- Elements with `opacity:0`.

The following are not removed:

- `<style>` and `<script>` children of `<defs>`.
- If a child of `<defs>` has no `id` attribute, it may contain descendants which have an `id` attribute. If this is the case, these descendants are moved up to become immediate children of the `<defs>` element.
- `<marker>` elements with `display:none`.
- `<g>` elements with `display:none` (these are converted to a `<defs>`, and their content is processed as above).
- Elements with `opacity:0` which are within a non-rendering element which is not removed.
7 changes: 2 additions & 5 deletions docs/preset-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@ The following plugins are included in `preset-default`, in the order that they a
- [inlineStyles](./plugins/inlineStyles.md)
- minifyStyles
- [cleanupIds](./plugins/cleanupIds.md)
- removeUselessDefs
- convertColors
- [removeUnknownsAndDefaults](./plugins/removeUnknownsAndDefaults.md)
- removeNonInheritableGroupAttrs
- removeUselessStrokeAndFill
- removeHiddenElems
- [removeHiddenElems](./plugins/removeHiddenElems.md)
- removeEmptyText
- minifyTransforms
- convertEllipseToCircle
- moveElemsAttrsToGroup
- moveElemsStylesToGroup
- collapseGroups
- convertShapeToPath
- combinePaths
- [minifyPathData](./plugins/minifyPathData.md)
- removeEmptyAttrs
- removeEmptyContainers
- removeUnusedNS
- [createGroups](./plugins/createGroups.md)

## Disable a Plugin

Expand Down
7 changes: 2 additions & 5 deletions docs/preset-next.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ The following plugins are included in `preset-next`, in the order that they are
- [inlineStyles](./plugins/inlineStyles.md)
- minifyStyles
- [cleanupIds](./plugins/cleanupIds.md)
- removeUselessDefs
- convertColors
- [removeUnknownsAndDefaults](./plugins/removeUnknownsAndDefaults.md)
- removeNonInheritableGroupAttrs
- removeUselessStrokeAndFill
- removeHiddenElems
- [removeHiddenElems](./plugins/removeHiddenElems.md)
- removeEmptyText
- minifyTransforms
- convertEllipseToCircle
- moveElemsAttrsToGroup
- moveElemsStylesToGroup
- collapseGroups
- convertShapeToPath
- combinePaths
- [minifyPathData](./plugins/minifyPathData.md)
- removeEmptyAttrs
- removeEmptyContainers
- removeUnusedNS
- [createGroups](./plugins/createGroups.md)
1 change: 1 addition & 0 deletions plugins/removeHiddenElems.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const description =
'removes non-rendered elements that are not referenced';

/**
* @see https://svgwg.org/svg2-draft/render.html#TermNeverRenderedElement
* @type {import('./plugins-types.js').Plugin<'removeHiddenElems'>}
*/
export const fn = (root, params, info) => {
Expand Down

0 comments on commit 6c18d57

Please sign in to comment.