html-to-css 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b6e922852517c80339a45220997648298601c15
4
+ data.tar.gz: 6953324840ce7ee68f7100feb3016efb90c205dc
5
+ SHA512:
6
+ metadata.gz: f4e15a6772890c096606f803b2c9a630a103b11dd1126e2c529d5fd11480cc24c6200f07cbff46c8a13e0c2c35718ca0dabf5fa6ea967f0391956b0596567ab2
7
+ data.tar.gz: 088dd101747daa174611c49db0c10bdda336c3ba868f2bb83229b9e54e0ff0beb604627d7737b9d3c03eb3aa6b7571ff8b6825b52b0a650a92a1203a1741b67d
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: html-to-css.rb
4
+
5
+ require 'rexle'
6
+
7
+
8
+ class HtmlToCss
9
+
10
+ def initialize(filename)
11
+
12
+ @doc = Rexle.new File.read(filename)
13
+ @selectors = []
14
+ @nocss = %w(title link)
15
+ @css = []
16
+
17
+ @elements = {
18
+ a: "background-color: :color; ",
19
+ body: "background-color: :color;
20
+ align: center;",
21
+ div: "background-color: :color;",
22
+ h1: "background-color: :color;
23
+ color: #fff;
24
+ font-family: Verdana, Arial, Helvetica, sans-serif;
25
+ font-size: 1.3em;",
26
+ h2: "background-color: :color;
27
+ color: #fff;
28
+ font-family: Verdana, Arial, Helvetica, sans-serif;
29
+ font-size: 1.3em;",
30
+ head: "background-color: :color;",
31
+ html: "background-color: :color;",
32
+ li: "background-color: :color;",
33
+ p: "background-color: :color;",
34
+ ul: "background-color: :color;"
35
+ }
36
+ end
37
+
38
+ def to_css()
39
+ scan @doc.root
40
+ @css.join "\n"
41
+ end
42
+
43
+ private
44
+
45
+ def scan(e, indent='', parent_selector='')
46
+
47
+ return if @nocss.include? e.name
48
+ attr = e.attributes
49
+
50
+ if attr.has_key?(:id) then
51
+ selector = '#' + attr[:id]
52
+ else
53
+ selector = (parent_selector + ' ' + e.name).strip
54
+ end
55
+
56
+ unless @selectors.include? selector then
57
+
58
+ @selectors << selector
59
+
60
+ if @elements.has_key?(e.name.to_sym) then
61
+ attributes = @elements[e.name.to_sym].strip.sub(':color','#a4f')
62
+ .gsub(/\n/,'').split(/;\s*/).join(";\n" + indent + ' ')
63
+ else
64
+ attributes = ''
65
+ end
66
+
67
+ @css << indent + selector + " {\n#{indent} #{attributes}\n#{indent}}"
68
+
69
+ end
70
+
71
+ parent_selector = selector unless selector == 'html'
72
+
73
+ indent += ' '
74
+ e.elements.each do |x|
75
+ scan x, indent, parent_selector
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+ if __FILE__ == $0 then
82
+ css = HtmlToCss.new('index.html').to_css
83
+ end
84
+
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ $��F�$#96�A���dp���O��<���ϜdD�q�sς��·�7i�3�zt�:)赘ۺkY܎P�ŞC�i��W�Cxj����P��F����%H'H.+��Yk�_<�Z
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html-to-css
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTEzMTAwOTE5MjE0MloXDTE0MTAwOTE5MjE0MlowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/I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 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: rexle
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ description:
51
+ email: james@r0bertson.co.uk
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - lib/html-to-css.rb
57
+ homepage: https://github.com/jrobertson/html-to-css
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.0.0.rc.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: html-to-css
81
+ test_files: []
metadata.gz.sig ADDED
Binary file