From 5f8139a6e3fcc95526df75050e5d01f9a44f0e2a Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sun, 11 Jul 2010 22:48:40 -0700 Subject: [PATCH] Add marker-start, marker-mid, marker-end to list of SVG properties that get converted to attributes --- release-notes.html | 1 + scour.py | 7 ++++++- testscour.py | 9 +++++++++ unittests/style-to-attr.svg | 9 +++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 unittests/style-to-attr.svg diff --git a/release-notes.html b/release-notes.html index 9561a61..cc63de3 100644 --- a/release-notes.html +++ b/release-notes.html @@ -21,6 +21,7 @@
  • Fix Bug 562784, typo in Inkscape description
  • Fix Bug 603988, do not commonize attributes if the element is referenced elsewhere.
  • Fix Bug 604000, correctly remove default overflow attributes.
  • +
  • Fix Bug 603994, fix parsing of <style> element contents when a CDATA is present
  • Fix Bug 583758, added a bit to the Inkscape help text saying that groups aren't collapsed if IDs are also not stripped.
  • Fix Bug 583458, another typo in the Inkscape help tab.
  • Fix Bug 594930, In a <switch>, require one level of <g> if there was a <g> in the file already. Otherwise, only the first subelement of the <g> is chosen and rendered.
  • diff --git a/scour.py b/scour.py index ac7c05a..9fb530c 100755 --- a/scour.py +++ b/scour.py @@ -35,6 +35,8 @@ # at rounded corners) # Next Up: +# - why are marker-start, -end not removed from the style attribute? +# - why are only overflow style properties considered and not attributes? # - only remove unreferenced elements if they are not children of a referenced element # - add an option to remove ids if they match the Inkscape-style of IDs # - investigate point-reducing algorithms @@ -69,7 +71,7 @@ except ImportError: APP = 'scour' VER = '0.25' -COPYRIGHT = 'Copyright Jeff Schiller, 2010' +COPYRIGHT = 'Copyright Jeff Schiller, Louis Simard, 2010' NS = { 'SVG': 'http://www.w3.org/2000/svg', 'XLINK': 'http://www.w3.org/1999/xlink', @@ -107,6 +109,9 @@ svgAttributes = [ 'font-weight', 'line-height', 'marker', + 'marker-end', + 'marker-mid', + 'marker-start', 'opacity', 'overflow', 'stop-color', diff --git a/testscour.py b/testscour.py index c467f97..ea1481d 100755 --- a/testscour.py +++ b/testscour.py @@ -1136,6 +1136,15 @@ class ShortenIDsInStyleCDATA(unittest.TestCase): self.assertEquals(docStr.find('somethingreallylong'), -1, 'Did not shorten IDs in the internal stylesheet') +class StyleToAttr(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/style-to-attr.svg') + line = doc.getElementsByTagName('line')[0] + self.assertEquals(line.getAttribute('stroke'), '#000') + self.assertEquals(line.getAttribute('marker-start'), 'url(#m)') + self.assertEquals(line.getAttribute('marker-mid'), 'url(#m)') + self.assertEquals(line.getAttribute('marker-end'), 'url(#m)') + # TODO: write tests for --enable-viewboxing # TODO; write a test for embedding rasters # TODO: write a test for --disable-embed-rasters diff --git a/unittests/style-to-attr.svg b/unittests/style-to-attr.svg new file mode 100644 index 0000000..570a802 --- /dev/null +++ b/unittests/style-to-attr.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file