gorgeous 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gorgeous.rb +3 -49
- data/lib/pretty.xslt +46 -0
- metadata +5 -4
data/lib/gorgeous.rb
CHANGED
@@ -9,8 +9,10 @@ class Gorgeous
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
PRETTY = File.expand_path('../pretty.xslt', __FILE__)
|
13
|
+
|
12
14
|
def self.pretty_xml(ugly)
|
13
|
-
tidy = Nokogiri::XSLT
|
15
|
+
tidy = Nokogiri::XSLT File.read(PRETTY)
|
14
16
|
tidy.transform(ugly).to_s
|
15
17
|
end
|
16
18
|
|
@@ -191,51 +193,3 @@ class Gorgeous
|
|
191
193
|
end
|
192
194
|
end
|
193
195
|
end
|
194
|
-
|
195
|
-
__END__
|
196
|
-
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
197
|
-
<xsl:output method="xml" encoding="UTF-8"/>
|
198
|
-
<xsl:param name="indent-increment" select="' '"/>
|
199
|
-
|
200
|
-
<xsl:template name="newline">
|
201
|
-
<xsl:text disable-output-escaping="yes">
|
202
|
-
</xsl:text>
|
203
|
-
</xsl:template>
|
204
|
-
|
205
|
-
<xsl:template match="comment() | processing-instruction()">
|
206
|
-
<xsl:param name="indent" select="''"/>
|
207
|
-
<xsl:call-template name="newline"/>
|
208
|
-
<xsl:value-of select="$indent"/>
|
209
|
-
<xsl:copy />
|
210
|
-
</xsl:template>
|
211
|
-
|
212
|
-
<xsl:template match="text()">
|
213
|
-
<xsl:param name="indent" select="''"/>
|
214
|
-
<xsl:call-template name="newline"/>
|
215
|
-
<xsl:value-of select="$indent"/>
|
216
|
-
<xsl:value-of select="normalize-space(.)"/>
|
217
|
-
</xsl:template>
|
218
|
-
|
219
|
-
<xsl:template match="text()[normalize-space(.)='']"/>
|
220
|
-
|
221
|
-
<xsl:template match="*">
|
222
|
-
<xsl:param name="indent" select="''"/>
|
223
|
-
<xsl:call-template name="newline"/>
|
224
|
-
<xsl:value-of select="$indent"/>
|
225
|
-
<xsl:choose>
|
226
|
-
<xsl:when test="count(child::*) > 0">
|
227
|
-
<xsl:copy>
|
228
|
-
<xsl:copy-of select="@*"/>
|
229
|
-
<xsl:apply-templates select="*|text()">
|
230
|
-
<xsl:with-param name="indent" select="concat ($indent, $indent-increment)"/>
|
231
|
-
</xsl:apply-templates>
|
232
|
-
<xsl:call-template name="newline"/>
|
233
|
-
<xsl:value-of select="$indent"/>
|
234
|
-
</xsl:copy>
|
235
|
-
</xsl:when>
|
236
|
-
<xsl:otherwise>
|
237
|
-
<xsl:copy-of select="."/>
|
238
|
-
</xsl:otherwise>
|
239
|
-
</xsl:choose>
|
240
|
-
</xsl:template>
|
241
|
-
</xsl:stylesheet>
|
data/lib/pretty.xslt
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
2
|
+
<xsl:output method="xml" encoding="UTF-8"/>
|
3
|
+
<xsl:param name="indent-increment" select="' '"/>
|
4
|
+
|
5
|
+
<xsl:template name="newline">
|
6
|
+
<xsl:text disable-output-escaping="yes">
|
7
|
+
</xsl:text>
|
8
|
+
</xsl:template>
|
9
|
+
|
10
|
+
<xsl:template match="comment() | processing-instruction()">
|
11
|
+
<xsl:param name="indent" select="''"/>
|
12
|
+
<xsl:call-template name="newline"/>
|
13
|
+
<xsl:value-of select="$indent"/>
|
14
|
+
<xsl:copy />
|
15
|
+
</xsl:template>
|
16
|
+
|
17
|
+
<xsl:template match="text()">
|
18
|
+
<xsl:param name="indent" select="''"/>
|
19
|
+
<xsl:call-template name="newline"/>
|
20
|
+
<xsl:value-of select="$indent"/>
|
21
|
+
<xsl:value-of select="normalize-space(.)"/>
|
22
|
+
</xsl:template>
|
23
|
+
|
24
|
+
<xsl:template match="text()[normalize-space(.)='']"/>
|
25
|
+
|
26
|
+
<xsl:template match="*">
|
27
|
+
<xsl:param name="indent" select="''"/>
|
28
|
+
<xsl:call-template name="newline"/>
|
29
|
+
<xsl:value-of select="$indent"/>
|
30
|
+
<xsl:choose>
|
31
|
+
<xsl:when test="count(child::*) > 0">
|
32
|
+
<xsl:copy>
|
33
|
+
<xsl:copy-of select="@*"/>
|
34
|
+
<xsl:apply-templates select="*|text()">
|
35
|
+
<xsl:with-param name="indent" select="concat ($indent, $indent-increment)"/>
|
36
|
+
</xsl:apply-templates>
|
37
|
+
<xsl:call-template name="newline"/>
|
38
|
+
<xsl:value-of select="$indent"/>
|
39
|
+
</xsl:copy>
|
40
|
+
</xsl:when>
|
41
|
+
<xsl:otherwise>
|
42
|
+
<xsl:copy-of select="."/>
|
43
|
+
</xsl:otherwise>
|
44
|
+
</xsl:choose>
|
45
|
+
</xsl:template>
|
46
|
+
</xsl:stylesheet>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gorgeous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Mislav Marohni\xC4\x87"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-15 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -30,6 +30,7 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- bin/gorgeous
|
32
32
|
- lib/gorgeous.rb
|
33
|
+
- lib/pretty.xslt
|
33
34
|
- README.md
|
34
35
|
has_rdoc: false
|
35
36
|
homepage: http://github.com/mislav/gorgeous
|