html_to_sliml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25456a84041738193047d7398c0d24233284fa34
4
+ data.tar.gz: 26141dff4380d6fab8164b9415ac1a14a3a23188
5
+ SHA512:
6
+ metadata.gz: 2a7b1cb45a5ef2e0c4e9ff63802c687ea6885a6568f051202647c4201e96c4aa48968c421303ab16e425bd4389e6a546975523e6887a4e39f6baaad10694296f
7
+ data.tar.gz: 193c3b9450d200bdc7e1aef2ba1aba8dbd3d151d6bdde7ea25d7ac7aa04b99aef0a694606f471d3d612e313cc1c8becdbe3388db66be0846ad0e0bd59999e5f5
Binary file
Binary file
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: html_to_sliml.rb
4
+
5
+ require 'rexle'
6
+
7
+
8
+ class HtmlToSliml
9
+
10
+ attr_reader :to_s
11
+
12
+ def initialize(html)
13
+
14
+ @to_s = ''
15
+ doc = Rexle.new(html)
16
+ @to_s << scanbuild(doc.to_a)
17
+
18
+ end
19
+
20
+ private
21
+
22
+ # format attributes
23
+ #
24
+ def fa(h)
25
+
26
+ "{%s}" % h.map {|k, v| "%s: %s" % [k, v.inspect]}.join(', ')
27
+
28
+ end
29
+
30
+ def scanbuild(x, indent=0)
31
+
32
+ name, attributes, *remaining = x
33
+
34
+ children = remaining.shift
35
+ text = ''
36
+
37
+
38
+ if children.is_a? Array then
39
+ nested = scanbuild(children, indent+1)
40
+ elsif children
41
+ text = children
42
+ end
43
+
44
+ pad = ' ' * indent
45
+
46
+ buffer = pad + name
47
+ buffer << ' ' + fa(attributes) if attributes.any?
48
+ buffer << ' ' + text unless text.strip.empty?
49
+
50
+
51
+ while remaining.any? do
52
+ children = remaining.shift
53
+ if children and children.is_a? Array then
54
+ buffer << "\n" + scanbuild(children, indent+1)
55
+ end
56
+ end
57
+
58
+ buffer
59
+ end
60
+
61
+
62
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html_to_sliml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
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
+ 8ixkARkWAmV1MB4XDTE1MTEwNTEwMzcwNFoXDTE2MTEwNDEwMzcwNFowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAMKjD7IXBUj3lO4vFCrwcJi/J/1TTex/bTnsFO2EzJQUu2gw5S7shUnNv3tn
19
+ 4IcPOJuFgTcgJGlb3Rfc++Deosoh68Rpz3QvtxQpYdB3ISOA3jd0wZ+vJlPSgdYC
20
+ 2qtyyDhR21f4j/9wHDHbRIFnUkdP8G8XCTqRrs5vXDOlYtv9Ey2CmAzGpTvMLqxK
21
+ AvQ/C0vZU+8KDok1mir8Edg+tnG8ME4bDmz53lbnR3NnP4iIjD4sqwYH1MN/qvLw
22
+ PZQCU2HH0b6iPZRxiGl7K58nMCexUYMsJlnERf6fs8YpbQUoZR1ZN5lEWmC4Wzk/
23
+ eq6ZS5/DT2W8p+LhOEboHqx5qLECAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUFIVFHBlvlLFuRWlJ50BDnu2NpoUwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAu52wMHKN
27
+ 5l/3cPp7S7RJhLP9jl4gSDmZK4mK+HtDEcbg8j1ll7eKo/mVE9K7UH3e6Kd/0gfg
28
+ 3l51u/7VW6SZsAW9GNJuSLnKKa3bP6nUsCIqtrX9zQsg2qbsBTY23XGK+zE6imSf
29
+ 328y+bbFlNi75eubssz1IAtCk5Df58ANOu51b7pkdD9m5gYvAwVGRkiNkuwLL/Mg
30
+ aJSrBycCxIfnm3tVXlSVI03/4G/RQ0hiU+gC65cOc5ET6oI6bQbYJ1Jpwj3PUHGh
31
+ 4Z/DQm8z4W/li13IZeubZYbymi3w3DqOhX8YLr1HKDrLMpko+ycSs+YjnksOsO+1
32
+ gcTNwpS8Ex5PhA==
33
+ -----END CERTIFICATE-----
34
+ date: 2015-11-05 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: '1.3'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.8
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.3'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 1.3.8
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/html_to_sliml.rb
63
+ homepage: https://github.com/jrobertson/html_to_sliml
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: An experimental gem to transform HTML to Sliml (a kind of Slim markdown)
87
+ test_files: []
@@ -0,0 +1,2 @@
1
+ �B�yGJ�KP�(E�f�
2
+ o�Ȉ@q �V.����<�k��b:,�����_�sB�>��fn�D&8�}��!�)����|ٴ-ƯdP���;XPuee�����}��xRI���G�O9���!������<��fOyP��쀼Ty��5v[��ts�@��}����:� ��)��q����FjU��b�ߚrR��ᚍ�����<p�Q"���N�oH���FGl���z`4C��yXg��[H�}J�ի��l���^G�Y