scour
scour copied to clipboard
Add --remove-doctype option to remove DOCTYPE element
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
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.
What is the point of removing the doctype? The resulting document isn't valid XML anymore ...
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 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?
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.
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.
Can you add this --keep-doctype option?
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 ?