Commit graph

257 commits

Author SHA1 Message Date
Michael Witten
0a146b7fef tests: Add unit tests for the escaping of quote characters in attribute values 2017-09-03 18:07:27 +02:00
Michael Witten
7e14cd352f scour.py: Escape quote characters in attribute values, as necessary and minimally
Either double quotes or single quotes are escaped; the choice is made
so as to minimize the length of the escaped string.
2017-09-03 18:07:27 +02:00
Michael Witten
f14784b01f scour.py: handle id' and xml:id' in the same code that handles other attributes 2017-08-26 19:11:37 +00:00
Michael Witten
fef2786c5e scour.py: minor rearrangement for the sake of clarity
There has been a minor rearrangement of the code that handles the children
of the element being serialized: The relevant `if' statement has had its
condition effectively negated and thus has also had its consequent and
alternative swapped; now, there is a very short consequent, followed by a
very long alternative, rather than a very long consequent followed by a
very short alternative.
2017-08-26 19:11:37 +00:00
Michael Witten
695a91e447 scour.py: Satisfy the identing rules of PEP8 2017-08-26 18:44:58 +02:00
Michael Witten
7ee5f9774d scour.py: Use named constants rather than literal integers for `nodeType' 2017-08-26 18:44:58 +02:00
Eduard Braun
e36cd4832a Scour v0.36 2017-08-06 04:55:59 +02:00
Eduard Braun
49f3664f82 make flake8 happier 2017-08-06 04:55:43 +02:00
Eduard Braun
53d87ed35a make flake8 happy 2017-08-06 04:47:33 +02:00
Eduard Braun
c089448bb5 Update project description and use in both, README.md and setup.py 2017-08-06 04:38:33 +02:00
Eduard Braun
e0bfad272b Update README.md
- the original page only has a link these days
- project identity should be established by now
2017-08-06 04:13:23 +02:00
Eduard Braun
992b6850c6 Update HISTORY.md 2017-08-06 03:52:20 +02:00
Eduard Braun
cc592c8e8a Improve and fix behaviour when collapsing straight paths segments (#146)
* Do not collapse straight path segments in paths that have intermediate markers (see #145). The intermediate nodes might be unnecessary for the shape of the path, but their markers would be lost.
* Collapse subpaths of moveto `m` and lineto `l` commands if they have the same direction (before we only collapsed horizontal/vertical `h`/`v` lineto commands)
* Attempt to collapse lineto `l` commands into a preceding moveto `m` command (these are then called "implicit lineto commands")
* Preserve empty path segments if they have `stroke-linecap` set to `round` or `square`. They render no visible line but a tiny dot or square.
2017-05-18 00:53:25 +02:00
Ville Skyttä
75bacbc8e6 Python 3.6 invalid escape sequence deprecation fix (#144)
(see https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior)
2017-05-09 22:07:06 +02:00
Ville Skyttä
62b16c11d8 Spelling fixes 2017-05-09 21:45:04 +02:00
Eduard Braun
5bfffc2ca8 Hardcode printing of "flowtext" warning to stderr
Third-party applications obviously can not handle additional output on stdout nor can they be expected to do any weird stdout/sterr redirection as we do via `options.stdout`
We probably shouldn't print anything in `scourString()` to start with unless we offer an option to disable all non-SVG output for third-party libraries to use.
2017-04-30 04:13:44 +02:00
Eduard Braun
98e3040645 Add unittest for --set-c-precision (7cb0d36d72) 2017-02-25 19:44:18 +01:00
Eduard Braun
51c1e6af23 Improve options handling for precision options
- prevent '--set-precision=0' by requiring >=1
- warn user if '--set-c-precision' > '--set-precision' instead of silently ignoring the value
- some code cleanup
2017-02-25 19:44:18 +01:00
Eduard Braun
c2a65a772e Some code refactoring 2017-02-25 19:44:18 +01:00
Eduard Braun
12237e01c8 Refactor logic to detect control points from 7cb0d36d72 and also include control points of quadratic Bézier curve commands ("q") 2017-02-25 19:44:18 +01:00
Eduard Braun
090884a70f Don't force whitespace for elliptical paths (fixes #89)
This was only required in an early draft of the SVG spec (an error that was corrected later, see [1,2])

[1] https://github.com/scour-project/scour/issues/89#issuecomment-244216600
[2] https://github.com/scour-project/scour/issues/89#issuecomment-244337118
2017-02-25 19:44:18 +01:00
Eduard Braun
2ebe9741b2 Rename a variable plus some editing of comments 2017-02-25 19:44:18 +01:00
Eduard Braun
a7e7b4c21d Cleanup options.
Also omit short option strings of advanced options for now (if we offer them again in future, they should be chosen very carefully as should the options for which we offer them)
2017-02-23 23:39:27 +01:00
pborunda
7cb0d36d72 Improve precision options for smaller output size (#131)
Add a separate precision option for curve control points (--set-c-precision)
This can considerably reduce file size with marginal effect on visual appearance.
2017-02-23 22:00:32 +01:00
Eduard Braun
ffeb76c894 Unittests: remove temporary file 'testscour_temp.svg' after running tests 2017-02-22 22:13:04 +01:00
Eduard Braun
f7d6406d38 Work around https://github.com/travis-ci/travis-ci/issues/3080 as pypy throws if 'ping' can't be executed 2017-02-22 22:07:17 +01:00
Eduard Braun
0f6d9be4e2 Add sudo: false to .travis.yml for faster execution of jobs 2017-02-19 18:06:57 +01:00
Eduard Braun
3b41d3a547 Add Python 3.6 to tests and simplify .travis.yml by using 'tox-travis' 2017-02-19 18:04:36 +01:00
Eduard Braun
0ffefcd8bb Unittests for --enable-viewboxing 2017-02-19 16:10:01 +01:00
Eduard Braun
01cb120d71 Reduce precision of lengths in viewBox
This fixes #127.
Also simplify splitting of viewBox lengths and avoiding a "FutureWarning: split() requires a non-empty pattern match" at the same time
2017-02-19 16:10:01 +01:00
Eduard Braun
3e4c8d793f Typo in unittest svg file 2017-02-19 15:19:53 +01:00
Eduard Braun
f5a61eeeb3 Even better fix for 8f87118725
(previous solution still did not work for numbers like 123.4 with precision < 3)
2017-02-19 00:57:00 +01:00
Eduard Braun
7c2e035644 Merge pull request #133 from Ede123/precision
Some fixes for `scourUnitlessLength()`
2017-02-18 19:45:51 +01:00
Eduard Braun
a69efb3a55 Add unittests for b00b374e64 and 8f87118725 2017-02-18 19:36:19 +01:00
Eduard Braun
8f87118725 Only use number representation with reduced precision if it is shorter than the initial representation.
Before it could happen that "123" was replaced with "1e3" if precision was set to 1 which is obviously not desirable.
2017-02-18 19:01:26 +01:00
Eduard Braun
b00b374e64 Fix generation of non-scientific number representation.
Before numbers often were already in scientific notation due to the str() implementation of Decimal leading to strange optimization results.
2017-02-18 18:06:09 +01:00
Eduard Braun
210c5f64ab Update HISTORY.md 2016-11-27 19:10:29 +01:00
Eduard Braun
25549b35d3 Some whitespace fixes to make newer versions of flake8 happy 2016-11-27 18:52:39 +01:00
Eduard Braun
6cf8c2b7d9 call sanitizeOptions() in start() to prevent a third-party breakage 2016-11-27 18:52:39 +01:00
Eduard Braun
c45f050fe6 Update HISTORY.md (0.35 has been released) 2016-10-25 23:16:47 +02:00
Eduard Braun
d9b369864d Reimplement generateDefaultOptions() by simply calling sanitizeOptions() 2016-09-25 19:02:19 +02:00
Eduard Braun
49cb542689 Make sanitizeOptions() work with an empty parameter list 2016-09-25 18:49:05 +02:00
Eduard Braun
285d73e5a6 Fix statistics out put for "Number of comments removed" 2016-09-25 15:44:07 +02:00
Eduard Braun
2fe7152a1e Fix logic from 4a5b924d37 (which was still wrong after 4410f91dad) 2016-09-25 15:34:28 +02:00
Eduard Braun
91ee9d2112 Merge pull request #120 from Ede123/raster_images
Fix embedding of raster images
2016-09-23 23:23:21 +02:00
Eduard Braun
de1441fd58 Exclude (system specific) absolute paths from test file and add a unittest that creates/tests absolute paths on-the-fly 2016-09-23 23:16:19 +02:00
Eduard Braun
902e112a96 Add unittests for embedding rasters (and --disable-embed-rasters) 2016-09-23 23:14:56 +02:00
Eduard Braun
8cc97601c4 scourXmlFile(): Set specified 'filename' as input filename so relative references will work 2016-09-23 22:32:32 +02:00
Eduard Braun
462460a512 Fix embedRasters() function.
It was not Python 3 compatible and usually would not have worked with local files.
2016-09-23 22:30:43 +02:00
Eduard Braun
8d20805976 Add three images (for usage with a future unittest) 2016-09-18 22:41:24 +02:00