On Tue, 1 May 2018 00:28:27 +0200
Marc Jeanmougin <marc@...3080...> wrote:
> Hi,
>
> You can delete the rdf thing, it's just metadata, and probably also
> the aria attribute, but for the flowroot thing, you have to select
> your (flowing) text elements in inkscape and convert them to real
> text (Text -> Convert to text) or you may lose text.
Thanks Marc!
It turns out I was able to delete all three without effect I was able
to see on quick inspection.
Because I had several such Inkscape authored SVG files, I created a
shellscript calling a Python3 program that automatically removes most
of the epubcheck error causers:
SHELLSCRIPT trim_svg.sh:
============================================================ ============
#!/bin/sh
fname=$1
bakname=$fname.bak
cp -p $fname $bakname
inkscape --vacuum-defs $fname
inkscape --export-plain-svg $fname.2 $fname
./trim_svg.py $fname.2
cp -p $fname.2a $fname
============================================================ ============
Python3 program trim_svg.py
============================================================ ============
#!/usr/bin/python3
import sys
import xml.etree.ElementTree as ET
import re
def main():
# Handle filename and args
if len(sys.argv) != 2:
print("USAGE: trim_svg.py infname.")
print("Aborting.")
sys.exit(1)
else:
infname = sys.argv[1]
# Parse the original file
parser = ET.XMLParser()
try:
tree = ET.parse(infname, parser=parser)
except Exception as exception:
print("Parse failure, aborting!", file=sys.stderr)
print(exception, file=sys.stderr)
exit(1)
root = tree.getroot()
# Delete the necessary
to_delete=[]
for parent in tree.getiterator():
for child in parent:
if re.search("RDF$",child.tag) or
re.search("flowRoot$",child.tag):
to_delete.append([parent, child])
elif "aria-label" in child.attrib:
del(child.attrib["aria-label"])
for pair in to_delete:
pair[0].remove(pair[1])
tree.write(infname + "a",encoding="UTF-8",short_empty_elements=True)
if __name__ == "__main__":
main()
============================================================ ============
The epubcheck program is a petty diva snowflake that gripes about the
slightest deviation not only in your ePub files, but also in the .svg
files it displays. Getting to zero errors, zero warnings is a pain in
the posterior, but guarantees that your ePub will be readable on any
reasonable device, and will look good on all reasonable devices. It's
overkill for a lot of people, but if you're ever in the position of
widely distributing ePub files, you might use it, and if so, this
shellscript and Python program get rid of the vast majority of
error-triggering Inkscape derived SVG features. Be sure to back up the
original SVGs in case my programs visibly damage them.
SteveT
Steve Litt
April 2018 featured book: Troubleshooting Techniques
of the Successful Technologist
http://www.troubleshooters.com/techniques
------------------------------------------------------------ ------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-user mailing list
Inkscape-user@...3230...9...sourceforge.net
https://lists.sourceforge.net/lists/listinfo/inkscape-user