From ac5bb8f275dd9b2746fe6d433f1c08c1c3bd3d61 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 19 Jun 2019 21:26:42 +0200 Subject: [PATCH] Add XSL stylesheet to fix up SVG files The SVG output produced by external tools needs some postprocessing. This is implemented by this new XSL stylesheet. Issues are: - SVG produced by Ditaa does not add a viewBox attribute to the svg element, needed to make the image scalable. - SVG produced by Graphviz uses a stroke="transparent" attribute, which is not valid SVG. It appears to mostly work, but FOP complains. Other tweaks can be added over time. This reverts 7dc78d8ef3e62f7e06d7767c63dcede048377b9a and 29046c44f36099f4c979b1491fcf27db2f9184f9, which applied these fixes manually. --- .gitattributes | 1 - doc/src/sgml/images/Makefile | 12 +++++- doc/src/sgml/images/README | 11 ++--- doc/src/sgml/images/fixup-svg.xsl | 44 ++++++++++++++++++++ doc/src/sgml/images/gin.svg | 65 ++++++++++++++--------------- doc/src/sgml/images/pagelayout.svg | 66 ++++++++++++++---------------- 6 files changed, 119 insertions(+), 80 deletions(-) create mode 100644 doc/src/sgml/images/fixup-svg.xsl diff --git a/.gitattributes b/.gitattributes index 2b72ef7e55..3ac9997281 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,7 +13,6 @@ README.* conflict-marker-size=32 # Certain data files that contain special whitespace, and other special cases *.data -whitespace -*.svg whitespace=-blank-at-eol contrib/pgcrypto/sql/pgp-armor.sql whitespace=-blank-at-eol src/backend/catalog/sql_features.txt whitespace=space-before-tab,blank-at-eof,-blank-at-eol diff --git a/doc/src/sgml/images/Makefile b/doc/src/sgml/images/Makefile index bb508dd0dd..1e7993020b 100644 --- a/doc/src/sgml/images/Makefile +++ b/doc/src/sgml/images/Makefile @@ -8,11 +8,19 @@ ALL_IMAGES = \ DITAA = ditaa DOT = dot +XSLTPROC = xsltproc all: $(ALL_IMAGES) -%.svg: %.gv +%.svg.tmp: %.gv $(DOT) -T svg -o $@ $< -%.svg: %.txt +%.svg.tmp: %.txt $(DITAA) -E -S --svg $< $@ + +# Post-processing for SVG files coming from other tools +# +# Use --novalid to avoid loading SVG DTD if a file specifies it, since +# it might not be available locally, and we don't need it. +%.svg: %.svg.tmp fixup-svg.xsl + $(XSLTPROC) --novalid -o $@ $(word 2,$^) $< diff --git a/doc/src/sgml/images/README b/doc/src/sgml/images/README index ade627bda2..07c4580255 100644 --- a/doc/src/sgml/images/README +++ b/doc/src/sgml/images/README @@ -22,6 +22,10 @@ Therefore, any tool used needs to be able to produce SVG. This directory contains makefile rules to build SVG from common input formats, using some common styling. +fixup-svg.xsl applies some postprocessing to the SVG files produced by +those external tools to address assorted issues. See comments in +there, and adjust and expand as necessary. + Both the source and the SVG output file are committed in this directory. That way, we don't need all developers to have all the tools installed. While we accept that there could be some gratuitous @@ -59,10 +63,3 @@ Notes: - The width should be set to something. This ensures that the image is scaled to fit the page in PDF output. (Other widths than 100% might be appropriate.) - -- SVG images should be scalable as they will be rendered in a variety - of places (web, PDF, etc.) as well as in different viewports - (desktop, mobile, etc.). To help the images successfully scale, - employ a "viewBox" attribute in the SVG tag. For example, - to create an image with a default width and height of 400x300, - you would use viewBox="0.00 0.00 400.00 300.00" diff --git a/doc/src/sgml/images/fixup-svg.xsl b/doc/src/sgml/images/fixup-svg.xsl new file mode 100644 index 0000000000..d6c46b362e --- /dev/null +++ b/doc/src/sgml/images/fixup-svg.xsl @@ -0,0 +1,44 @@ + + + + + + + + + + + 0 0 + + + + + + + + + + + + none + + + + + + + + + + diff --git a/doc/src/sgml/images/gin.svg b/doc/src/sgml/images/gin.svg index eacb5c8c16..04fe85ba44 100644 --- a/doc/src/sgml/images/gin.svg +++ b/doc/src/sgml/images/gin.svg @@ -1,14 +1,11 @@ - - + - + gin - + cluster01 @@ -47,7 +44,7 @@ -m1->e1 +m1->e1 @@ -58,7 +55,7 @@ -m1->n1 +m1->n1 @@ -69,7 +66,7 @@ -e1->e2 +e1->e2 @@ -80,7 +77,7 @@ -e1->e3 +e1->e3 @@ -91,13 +88,13 @@ -e1->e4 +e1->e4 -e2->e3 +e2->e3 @@ -108,7 +105,7 @@ -e2->e5 +e2->e5 @@ -120,13 +117,13 @@ -e2->e6 +e2->e6 -e3->e4 +e3->e4 @@ -137,7 +134,7 @@ -e3->e7 +e3->e7 @@ -149,7 +146,7 @@ -e4->e8 +e4->e8 @@ -161,13 +158,13 @@ -e4->e9 +e4->e9 -e5->e6 +e5->e6 @@ -178,19 +175,19 @@ -e5->p1 +e5->p1 -e6->e7 +e6->e7 -e7->e8 +e7->e8 @@ -202,7 +199,7 @@ -e7->p4 +e7->p4 @@ -213,13 +210,13 @@ -e7->p5 +e7->p5 -e8->e9 +e8->e9 @@ -231,7 +228,7 @@ -p1->p2 +p1->p2 @@ -243,13 +240,13 @@ -p1->p3 +p1->p3 -p2->p3 +p2->p3 @@ -261,7 +258,7 @@ -p5->p6 +p5->p6 @@ -273,13 +270,13 @@ -p5->p7 +p5->p7 -p6->p7 +p6->p7 @@ -290,7 +287,7 @@ -n1->n2 +n1->n2 @@ -301,7 +298,7 @@ -n2->n3 +n2->n3 @@ -312,7 +309,7 @@ -n3->n4 +n3->n4 diff --git a/doc/src/sgml/images/pagelayout.svg b/doc/src/sgml/images/pagelayout.svg index 3cf89f0a14..5b2caaf170 100644 --- a/doc/src/sgml/images/pagelayout.svg +++ b/doc/src/sgml/images/pagelayout.svg @@ -1,41 +1,35 @@ - - + + - - - - + + + + - - - - - - - - - - - - - - - - - - - PageHeaderData - Item - ItemId - ItemId - Item - Special + + + + + + + + + + + + + + + + + + + PageHeaderData + Item + ItemId + ItemId + Item + Special