1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00
Commit Graph

34 Commits

Author SHA1 Message Date
6e23b9cf56 Cover svg parser with tsdoc (#1584)
Moved to lib/parser.js. The code will be slightly simpler
when JSAPI will be removed in v3.
2021-09-23 21:45:22 +03:00
77102ed096 Add better parser errors (#1553)
Old SVGO errors were not very helpful. Packages like cssnano
(postcss-svgo) had to deal with a lot of issues which are hard to debug
with old errors.

```
Error: Error in parsing SVG: Unquoted attribute value
Line: 1
Column: 29
Char: 6
File: input.svg
```

New errors are more informative and may solve many struggles

```
Error: SvgoParserError: input.svg:2:29: Unquoted attribute value

  1 | <svg viewBox="0 0 120 120">
> 2 |   <circle fill="#ff0000" cx=60.444444" cy="60" r="50"/>
    |                             ^
  3 | </svg>
  4 |
```
2021-09-12 01:09:10 +03:00
c3695ae533 Migrate to jest (#1520)
Mocha doesn't have a lot of features provided by jest.
There is a great assertion library out of the box.
And the most cool feature is inline snapshots.
Mocha also hides errors which makes debugging a nightmare sometimes.
2021-08-12 18:06:10 +03:00
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
3e1bfd528d Convert attributes to xast with proxy fallback
There is a lot of attributes manipulation which is hard to remove at
once. In this diff I added `attributes` object and wrapped it as proxy
for `attrs` field.
2021-03-10 23:11:09 +03:00
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
c50decb438 Convert cdata and text nodes to xast
Ref https://github.com/syntax-tree/xast

More consistent naming and distinction by type looks a bit cleaner.
2021-03-10 16:16:11 +03:00
8622a5f31b Convert to xast doctype, instruction and comment nodes
Here we add [xast](https://github.com/syntax-tree/xast) support
to three basic nodes: doctype, instruction and comment

Some tests are rewritten instead of checking each field to `.include`
assertion which is able to match shape of object.
2021-03-10 14:10:40 +03:00
d1d6e5efe8 Remove prefix/local support in elements and attributes (#1413)
These parts of element and attribute name are easy to extract.
Now we can easily replace attrs with xast attributes object.
2021-03-10 13:26:15 +03:00
a99cc08e4f Format tests with prettier (#1380)
Will format the code with prettier in a few commits.
2021-02-27 23:17:47 +03:00
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
9f084cc086 Preserve whitespace in elements containing text (#1220) 2021-02-23 18:25:30 +03:00
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
8899f682b8 Remove coverage imports from tests 2021-02-15 02:41:28 +03:00
bc44ab3f29 Refactor assertions with chai expect 2021-02-14 15:12:41 +03:00
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
828a72a896 fix broken jsapi clone method (#854) 2018-09-15 13:57:47 +03:00
0b23ff63c2 Improvements on parsing error handling. 2016-02-29 01:03:16 +03:00
748756e18d Capture parsing errors, but no further. (Don't break tests.) 2016-02-28 23:09:32 +03:00
9cdb046383 Improved parser error handling.
Show output error position. Resolves #482
2016-02-08 00:36:56 +03:00
0d91a0455d Parse XML entities.
Fixes #225, fixes #272, fixes #314. Closes #476.
2016-01-04 20:22:11 +03:00
91300f3d88 Fixed test that uses String.prototype.includes to use indexOf instead 2015-12-28 20:20:08 -08:00
4800bf77ca Added tests for svg2js behavior if passed in malformed svg 2015-12-28 20:08:54 -08:00
1dd57cabe1 Istanbul + coveralls.io 2013-04-15 20:35:55 +03:00
270347e84c test/svg2js repair 2013-04-11 19:32:02 +03:00
a0d409389f yaml.js -> js-yaml; update outdated deps 2013-02-09 13:03:29 +02:00
ab5610a197 fix mocha-as-promised plug in node 0.6 2012-12-06 00:25:00 +02:00
354b2ed46a mocha + mocha-as-promised + chai + chai-as-promised + should + istanbul = <3 2012-12-05 23:53:13 +02:00
9155e8a9b4 more code coverage with Istanbul 2012-12-01 23:03:31 +02:00
5485010269 'use strict' motherfucker! do you use it?! 2012-11-27 22:51:31 +02:00
aa10a8b5de lib/svgo/ 2012-11-09 14:21:06 +02:00
acbaa170ee Istanbul code coverage 2012-11-05 12:14:38 +02:00
6d62e8b826 JSHint :-| 2012-10-12 22:40:30 +03:00
f0f4a48b33 test/ completely revised; every plugin now has at least one test 2012-10-03 18:15:05 +03:00