1
0
mirror of https://github.com/svg/svgo.git synced 2025-04-19 10:22:15 +03:00

24 Commits

Author SHA1 Message Date
Bogdan Chadkin
07f8d606e0
Implement preset-default plugin (#1513)
I saw complaints about `extendDefaultPlugins` api

- it cannot be used when svgo is installed globally
- it requires svgo to be installed when using svgo-loader or svgo-jsx
- it prevents using serializable config formats like json

In this diff I introduced the new plugin which is a bundle of all
default plugins.

```js
module.exports = {
  plugins: [
    'preset_default',
    // or
    {
      name: 'preset_default',
      floatPrecision: 4,
      overrides: {
        convertPathData: {
          applyTransforms: false
        }
      }
    }
  ]
}
```
2021-08-13 19:07:08 +03:00
Bogdan Chadkin
35b7356ff0
Pass parent node to visitor (#1517)
Wrapping each node with JSAPI class and passing parent to it is not
reliable. Parent may be changed but the reference will stay.

Here I wasn't able to detach comment from parent node for some reason.
Explicit parent node inferred while ast traverse is easier to debug and
work with. Eventually we will not need to wrap each node with JSAPI class.
2021-08-12 13:05:09 +03:00
Bogdan Chadkin
2c0c361074
Collect stylesheet once per plugin (#1456)
computeStyle(node) in isolation is quite slow utility because it
collects style elements across whole document, parses and sort them.

In this diff I splitted it into `collectStylesheet(root)` and
`computeStyle(stylesheet, node)` which are easy integrate with new
visitor plugin api.
2021-08-12 03:08:39 +03:00
Bogdan Chadkin
06110b4fc0 Convert mergePaths to visitor 2021-03-29 03:08:15 +03:00
Bogdan Chadkin
6f2f62c5ee
Access attributes directly (#1433)
Got rid from `.attrs`, `.attr()` and `.addAttr()` usages
2021-03-18 18:53:20 +03:00
Bogdan Chadkin
5314c12c99 Convert element children to xast
Ref https://github.com/syntax-tree/xast

Renamed content to children to match xast spec.
2021-03-11 12:29:13 +03:00
Bogdan Chadkin
e82a672bbf Prepare root and element nodes for xast
Ref https://github.com/syntax-tree/xast

- added type: root | element
- renamed elem to name
- replaced "elem" property checks with check for correct type
2021-03-10 18:49:26 +03:00
Bogdan Chadkin
de4fd79b57 Prevent merging path when marker-end style is specified
Ref https://github.com/svg/svgo/issues/1217 https://github.com/svg/svgo/issues/958 https://github.com/svg/svgo/issues/872
2021-03-06 00:37:03 +03:00
一丝
8d7cfa02c7
After ‘arcto’ path command(a or A) flags, spaces are no longer removed by default (#1353)
Co-authored-by: 壹丝 <jie.lijie@alibaba-inc.com>
2021-02-20 18:58:42 +03:00
GreLI
023013abf9 Use ’force’ option in ‘mergePaths’ only for paths with same attributes 2019-07-14 19:22:59 +03:00
Michael Irigoyen
b9905aa5ec (Fix #800) Add option to the mergePaths plugin, forcing all path attributes to be combined (#1084)
Add  option to the mergePaths plugin, forcing all path attributes to be combined
2019-07-13 22:25:21 +03:00
GreLI
258fecfa6b Remove spaces after ‘arcto’ path command flags 2019-07-13 16:18:08 +03:00
GreLI
a7f62d8984 Formatting 2015-06-21 19:13:41 +03:00
Yoshiya Hinosawa
8e6b365c40 Add --show-plugins option 2015-06-07 19:35:49 +09:00
Aidan Steele
dcab8e0c73 Small spelling typo in mergePaths 2015-05-18 11:59:54 +10:00
GreLI
d935bd0dd3 Avoid manipulations with paths that have animations. Fixes #321 2015-03-22 18:12:09 +03:00
GreLI
e1060df7dc Check path intersection while merging.
Fixes #253, resolves #260, fixes #298.
2015-03-22 18:06:40 +03:00
GreLI
e220b6cad0 Path data processing improvements.
Improved path data saving.
Collapse repeated now works at writing path data and doesn't affect pathJS to make further processing easier.
Resolves #204.
2015-03-17 22:03:17 +03:00
GreLI
15ded2773e Simplified mergePaths plugin even more 2015-03-15 13:17:06 +03:00
GreLI
20af96a6b5 Corrected path merging 2015-02-26 01:34:20 +03:00
GreLI
5e7caa49dc Code styling 2015-02-08 19:31:55 +03:00
Nathan Muir
ad375c8d9c Updated mergePaths to join paths with the same attributes & values. 2013-11-18 22:34:44 +02:00
deepsweet
04dccd16ca plugins/mergePaths: add space delimiter between z and m 2013-05-06 19:09:17 +03:00
deepsweet
9124bf809e plugins/mergePaths: new plugin 2013-04-11 21:15:41 +03:00