scour icon indicating copy to clipboard operation
scour copied to clipboard

Add --remove-doctype option to remove DOCTYPE element

Open ricardobeat opened this issue 8 years ago • 8 comments

The original script had a --remove-doctype option [1], was it intentionally removed?

[1] https://github.com/pwfisher/scour.py/blob/master/scour.py#L3183

ricardobeat avatar Jul 05 '16 10:07 ricardobeat

There seems to be confusion on what the original script is.

The link you gave is a personal repository and the addition was never part of official Scour.

Ede123 avatar Jul 05 '16 16:07 Ede123

What is the point of removing the doctype? The resulting document isn't valid XML anymore ...

oberstet avatar Jul 25 '16 10:07 oberstet

What is the point of removing...

The W3C does not recommend the usage of doctype for SVG. For SVG 1.2 there is also no doctype anymore. https://jwatt.org/svg/authoring/#doctype-declaration

The resulting document isn't valid XML anymore ...

So the exact opposite is the case (as given on the link above). Also the w3c.validator marks the SVG now invalid (but this seems an weakness of the validator) https://validator.w3.org/check?uri=https%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FSpecial%3AFilepath%2FMulticheck_Logo.svg&ss=1

Perhelion avatar Jul 31 '16 00:07 Perhelion

@Perhelion Ok, seems I was wrong on that. Thanks for pointing out!

So for SVG using a doctype is actively discouraged, and even for XML in general, it is optional. Consequently, there should be a --remove-doctype option with default true. @Ede123 opinions?

oberstet avatar Jul 31 '16 10:07 oberstet

I totally agree. (Since I mostly use Scour in combination with Inkscape and the latter always removes doctype declarations I never realized doctypes remained untouched.)

Doctype declarations are useless in almost all cases and only add unnecessary overhead. The only thing where they might be useful is for declaring entities (and then again I doubt many SVG would support that properly). Unless somebody specifically includes a doctype (and knows what they are doing) I'd day it's save to remove them by default.

Ede123 avatar Aug 13 '16 14:08 Ede123

It would make semantically more sense to call the option --keep-doctype and set it to false by default. Perhelion’s first link above also mentions that parts of the doctype can be included as attributes in the <svg> element in case of SVG 1.0 and 1.1. Maybe that is something Scour could perform as well.

Eitot avatar Aug 31 '16 15:08 Eitot

Can you add this --keep-doctype option?

pborunda avatar Feb 20 '17 20:02 pborunda

I need this and consider doing a PR for it. I'm a noob in python though :) @Ede123 is it something you would be able to make a release for, or should I look into how to package it myself ?

Telem avatar Apr 26 '24 07:04 Telem