Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac5bb8f

Browse files
committed
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 reverts7dc78d8 and29046c4, which applied these fixesmanually.
1 parent66013fe commitac5bb8f

File tree

6 files changed

+119
-80
lines changed

6 files changed

+119
-80
lines changed

‎.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ README.*conflict-marker-size=32
1313

1414
# Certain data files that contain special whitespace, and other special cases
1515
*.data-whitespace
16-
*.svgwhitespace=-blank-at-eol
1716
contrib/pgcrypto/sql/pgp-armor.sqlwhitespace=-blank-at-eol
1817
src/backend/catalog/sql_features.txtwhitespace=space-before-tab,blank-at-eof,-blank-at-eol
1918

‎doc/src/sgml/images/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ ALL_IMAGES = \
88

99
DITAA = ditaa
1010
DOT = dot
11+
XSLTPROC = xsltproc
1112

1213
all:$(ALL_IMAGES)
1314

14-
%.svg:%.gv
15+
%.svg.tmp:%.gv
1516
$(DOT) -T svg -o$@$<
1617

17-
%.svg:%.txt
18+
%.svg.tmp:%.txt
1819
$(DITAA) -E -S --svg$<$@
20+
21+
# Post-processing for SVG files coming from other tools
22+
#
23+
# Use --novalid to avoid loading SVG DTD if a file specifies it, since
24+
# it might not be available locally, and we don't need it.
25+
%.svg:%.svg.tmp fixup-svg.xsl
26+
$(XSLTPROC) --novalid -o$@$(word 2,$^)$<

‎doc/src/sgml/images/README

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Therefore, any tool used needs to be able to produce SVG.
2222
This directory contains makefile rules to build SVG from common input
2323
formats, using some common styling.
2424

25+
fixup-svg.xsl applies some postprocessing to the SVG files produced by
26+
those external tools to address assorted issues. See comments in
27+
there, and adjust and expand as necessary.
28+
2529
Both the source and the SVG output file are committed in this
2630
directory. That way, we don't need all developers to have all the
2731
tools installed. While we accept that there could be some gratuitous
@@ -59,10 +63,3 @@ Notes:
5963
- The width should be set to something. This ensures that the image
6064
is scaled to fit the page in PDF output. (Other widths than 100%
6165
might be appropriate.)
62-
63-
- SVG images should be scalable as they will be rendered in a variety
64-
of places (web, PDF, etc.) as well as in different viewports
65-
(desktop, mobile, etc.). To help the images successfully scale,
66-
employ a "viewBox" attribute in the SVG tag. For example,
67-
to create an image with a default width and height of 400x300,
68-
you would use viewBox="0.00 0.00 400.00 300.00"

‎doc/src/sgml/images/fixup-svg.xsl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3+
xmlns:svg="http://www.w3.org/2000/svg"
4+
version="1.0">
5+
6+
<!--
7+
Transform the SVG produced by various tools, applying assorted fixups.
8+
-->
9+
10+
<!--
11+
Add viewBox attribute to svg element if not already present. This allows the
12+
image to scale.
13+
-->
14+
<xsl:templatematch="svg:svg">
15+
<xsl:copy>
16+
<xsl:iftest="not(@viewBox)">
17+
<xsl:attributename="viewBox">
18+
<xsl:text>0 0 </xsl:text>
19+
<xsl:value-ofselect="@width"/>
20+
<xsl:text> </xsl:text>
21+
<xsl:value-ofselect="@height"/>
22+
</xsl:attribute>
23+
</xsl:if>
24+
<xsl:apply-templatesselect="@* | node()"/>
25+
</xsl:copy>
26+
</xsl:template>
27+
28+
<!--
29+
Fix stroke="transparent" attribute, which is invalid SVG.
30+
-->
31+
<xsl:templatematch="@stroke[.='transparent']">
32+
<xsl:attributename="stroke">none</xsl:attribute>
33+
</xsl:template>
34+
35+
<!--
36+
copy everything else
37+
-->
38+
<xsl:templatematch="@* | node()">
39+
<xsl:copy>
40+
<xsl:apply-templatesselect="@* | node()"/>
41+
</xsl:copy>
42+
</xsl:template>
43+
44+
</xsl:stylesheet>

‎doc/src/sgml/images/gin.svg

Lines changed: 31 additions & 34 deletions
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp