Bogdan Chadkin
36391564f2
Preserve stroke-width when marker-end is specified
2021-02-24 17:29:29 +03:00
Bogdan Chadkin
091172a392
Fix <tspan> inside of <a>
2021-02-24 14:10:33 +03:00
Bogdan Chadkin
9de471a0f4
Handle nested textual tags
...
This bug was also catched by regression tests. Single state was
overriden in opentag/closetag callbacks. Using stack state solved the
problem with nested textual tags.
Now many whitespaces bugs should go away.
2021-02-24 00:58:11 +03:00
Bogdan Chadkin
4b4259bc60
Fix parsing xml entities ( #1371 )
...
Ref https://github.com/svg/sax/releases/tag/v0.1.1
This fixes enother case in [regression tests](https://github.com/svg/svgo/pull/1357 ).
2021-02-23 22:49:28 +03:00
Bogdan Chadkin
c1d5f0f7a9
Keep empty <g> when filter attributes is specified
2021-02-23 22:36:47 +03:00
Bogdan Chadkin
776ec1e71b
Fix incorrect xml:space default
2021-02-23 18:43:28 +03:00
Max Goodhart
9f084cc086
Preserve whitespace in elements containing text ( #1220 )
2021-02-23 18:25:30 +03:00
Bogdan Chadkin
a1fcd034fe
Disable convertStyleToAttrs plugin by default ( #1365 )
...
Ref https://github.com/svg/svgo/issues/1362 https://github.com/svg/svgo/issues/1360
From the [spec](https://www.w3.org/TR/SVG11/styling.html#UsingPresentationAttributes ):
> Presentation attributes have lower priority than other CSS style rules specified in author style sheets or ‘style’ attributes.
Though we replace inline styles with attributes without checking if
thare is any `<style>` element. This makes the plugin unsafe and it
should not be enabled by default.
2021-02-23 00:28:09 +03:00
Bogdan Chadkin
a855b40ec5
Fail when specified config is wrong or json is specified
2021-02-22 23:50:42 +03:00
Bogdan Chadkin
9b97e06ef6
Fix empty <svg /> in cleanupIDs plugin
2021-02-21 14:50:55 +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
XhmikosR
df14f37c48
test/coa/_index.js: Fix regex ( #1347 )
...
`.` means any character but we want to match the literal `.`
2021-02-20 17:05:04 +03:00
Bogdan Chadkin
d9f68d3be0
[removeElementsByAttr] fix removing elements when class is empty
...
Ref https://github.com/svg/svgo/issues/937
Regexp didn't not cover the case when class list is empty.
2021-02-20 16:54:46 +03:00
Bogdan Chadkin
7f4e05297a
[convertEllipseToCircle] fix ellipse without radius
...
Ref https://github.com/svg/svgo/issues/1264
2021-02-20 12:50:36 +03:00
Bogdan Chadkin
ea82cc2880
Report parsing errors with filename
2021-02-20 00:59:54 +03:00
Christian Ruigrok
b9880491b5
[reusePaths] fix excessive defs tag ( #1201 )
2021-02-19 23:56:20 +03:00
Bogdan Chadkin
82778c872d
Reduce browser build size 1450kB -> 820kB
2021-02-19 15:34:37 +03:00
Bogdan Chadkin
a7cc20bb43
Setup recommended eslint preset ( #1345 )
...
This is usually enough to prevent silly mistakes.
Formatting will be done by prettier after merging pull requests.
2021-02-19 15:26:07 +03:00
Bogdan Chadkin
330e78b479
Fix reporting of config errors ( #1342 )
...
Errors are swallowed while resolving.
2021-02-19 12:11:35 +03:00
Bogdan Chadkin
082aee027d
Fix plugins order ( #1334 )
...
Ref https://github.com/svg/svgo/issues/1333
While refactoring broke plugin order.
2021-02-18 17:46:28 +03:00
Bogdan Chadkin
efa62c8e30
Fix multipass ( #1332 )
...
Ref https://github.com/svg/svgo/issues/1330 https://github.com/svg/svgo/issues/1148 https://github.com/svg/svgo/issues/1133 https://github.com/svg/svgo/pull/1227 https://github.com/svg/svgo/issues/985 https://github.com/svg/svgo/issues/943
Took tests from https://github.com/svg/svgo/pull/1177
2021-02-18 14:12:27 +03:00
Sebastian Kreft
c9a3aea858
Path intersection was not checking paths with circles. ( #1229 )
...
As an optimization the path intersection was checking the paths had three or more elements, caliming that otherwise there was nothing to fill. However a semi circle would actually contain 2 points.
Fixes #1048 .
This adds a simplified test case for the 2 offending files reported in the issue.
2021-02-17 23:50:08 +03:00
Bogdan Chadkin
7a4217db4b
Replace fs-extra with del
2021-02-16 19:51:05 +03:00
Bogdan Chadkin
2236d0fd60
Upgrade mocha and refactor cli tests with async/await
2021-02-16 19:45:25 +03:00
Bogdan Chadkin
a6f14018ee
Implement loadConfig utility ( #1328 )
...
Ref https://github.com/svg/svgo/issues/1327
Config file now can only be js. `svgo.config.js` is searched by default.
Otherwise any js module specified in `--config` cli flag.
Config loader is exposed in entry point as `loadConfig(configFile, cwd)`.
2021-02-16 19:11:13 +03:00
Bogdan Chadkin
d273b26605
Provide es module bundle for browser ( #1326 )
...
The was a lot of requests to provide browser compatible module. In this
diff I added `svgo/dist/svgo.browser.js` bundle and tested it with
playwright.
2021-02-16 19:11:01 +03:00
Bogdan Chadkin
b1dafc6780
Implement default plugins and plugins list extending
2021-02-15 22:20:05 +03:00
Bogdan Chadkin
c9c7871e0d
Simplify svgo api ( #1325 )
...
Dropped SVGO class and provided "optimize" function with svg and config
as inputs and "createContentItem".
2021-02-15 18:32:50 +03:00
Bogdan Chadkin
225bfbb053
Move config processing into optimize
2021-02-15 16:57:01 +03:00
Bogdan Chadkin
1b776ffea5
Simplify plugins configuration ( #1324 )
...
- replaced named plugin object with "name" field
- dropped support for params in plugin object; use only params to pass plugin options
- dropped support for "boolean plugins"; use active field instead
```diff
-{
- pluginName: {
- fn,
- params: {},
- ...params
- }
-}
+{
+ name: 'pluginName',
+ fn,
+ params: {}
+}
```
2021-02-15 14:30:09 +03:00
Bogdan Chadkin
6cecd76f62
Remove config extending and full flag support
2021-02-15 13:12:29 +03:00
Bogdan Chadkin
2965e8ccdb
Drop plugin by path support and load builtins statically
2021-02-15 12:00:45 +03:00
Bogdan Chadkin
8899f682b8
Remove coverage imports from tests
2021-02-15 02:41:28 +03:00
Bogdan Chadkin
a1c1b7f443
Remove json string as --config value support
2021-02-14 17:44:18 +03:00
Bogdan Chadkin
bc44ab3f29
Refactor assertions with chai expect
2021-02-14 15:12:41 +03:00
Bogdan Chadkin
1dc5ee3ee1
Make optimize synchronous ( #1322 )
...
Ref https://github.com/svg/svgo/issues/1015
Looks like `sax` is synchronous and we do not need to listen "end"
event. This allows to avoid all callbacks and make `optimize` method
synchronous.
2021-02-14 14:59:50 +03:00
Bogdan Chadkin
57aecc50ac
Replace coa with commander ( #1293 )
...
Ref https://packagephobia.com/result?p=coa https://packagephobia.com/result?p=commander
Coa was not updated for 2 years already and has outdated dependencies.
In this diff I replaced it with commander which has simpler syntax, none
dependencies and require arguments out of the box. Also array argument
is set syntactically which means more user-friendly "help".
2021-02-13 22:23:19 +03:00
alexpavlovich
77464801e7
Fix cleanupIDs if defs is last elem of svg
2019-11-09 21:41:17 +03:00
Cyrille David
1152257505
Perform cleanupIDs
optimization when style/script tag is empty
...
cleanupIDs plugin is disabled when a script or style tag is present. I
assume that this is because they might contain an id.
If these tags are empty there is no point in not cleaning the id though.
When running svgo with the option `multipass: true`, it allows us to
first run `inlineStyles` plugin to empty the style tag. Then, we can run
`cleanupIDs` plugin.
2019-11-08 22:58:43 +03:00
GreLI
6db82a3323
Correct test
2019-11-08 18:40:25 +03:00
Sviatoslav Bulbakha
fafcbd7bd0
Fix prefixIds
plugin error with animations
...
Fix #848
2019-11-08 18:36:45 +03:00
GreLI
fdf9236d12
Add test for collapsing of repeated commands
2019-11-05 19:32:02 +03:00
James Thomson
0e6b0ad8e5
Fix 'cleanupIDs' minify bug due to preserved IDs
...
Prevent 'cleanupIDs' plugin from producing a preserved ID, including one
which matches a preserved prefix, when minifying.
Closes #1158
2019-10-29 22:54:36 +03:00
strarsis
67be534d30
Update csso to 4.0.2 (+semicola in styles test) ( #1172 )
...
Add test with SVG with double semicola (;;) in styles for reproducing csso bug.
Update css-tree to 1.0.0-alpha.37 (as it is also used by csso 4.0.2).
2019-10-29 22:47:09 +03:00
GreLI
e1dd31cf84
Fix 180deg ‘convertTransform’
...
Fix NaN after Math.acos due to error making illegal value out of bounds
Fix #1101
2019-07-14 18:51:50 +03:00
GreLI
8671c4c3df
Fix incorrect prev arc segment angle calculation.
...
Close #1109
2019-07-14 12:07:59 +03:00
strarsis
5ee68c4808
Add options to prefixIds plugin for selectively prefixing IDs and/or classes.
2019-07-13 22:51:06 +03:00
Taylor Hunt
8e45fa2d58
Add ‘ellipseToCircle’ plugin
...
Converts non-eccentric ellipse elements to circle elements.
Adobe Illustrator seems to be fond of using ellipses even if their rx === ry.
2019-07-13 22:31:22 +03:00
Adi Pascu
31e6a8cb65
Make removeDimensions add viewBox if it's missing
2019-07-13 22:27:47 +03:00
GreLI
4dfbd76d59
Fix final sorting condition in ‘sortDefsChildren’
2019-07-13 21:43:36 +03:00