html2haml 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.markdown +10 -0
- data/MIT-LICENSE +1 -1
- data/README.md +23 -3
- data/lib/html2haml/html.rb +8 -0
- data/lib/html2haml/html/erb.rb +1 -1
- data/lib/html2haml/version.rb +1 -1
- data/test/erb_test.rb +9 -0
- data/test/html2haml_test.rb +35 -0
- metadata +110 -115
data/Changelog.markdown
ADDED
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2006-
|
1
|
+
Copyright (c) 2006-2013 Hampton Catlin, Nathan Weizenbaum and Norman Clarke
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
4
|
this software and associated documentation files (the "Software"), to deal in
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Html2haml
|
2
2
|
|
3
|
-
Converts HTML to Haml.
|
4
|
-
gem.
|
3
|
+
Converts HTML to Haml.
|
5
4
|
|
6
5
|
## Installation
|
7
6
|
|
@@ -15,7 +14,7 @@ And then execute:
|
|
15
14
|
|
16
15
|
Or install it yourself as:
|
17
16
|
|
18
|
-
$ gem install html2haml
|
17
|
+
$ gem install html2haml
|
19
18
|
|
20
19
|
## Usage
|
21
20
|
|
@@ -38,3 +37,24 @@ See `html2haml --help`:
|
|
38
37
|
--unix-newlines Use Unix-style newlines in written files.
|
39
38
|
-?, -h, --help Show this message
|
40
39
|
-v, --version Print version
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
Copyright (c) 2006-2013 Hampton Catlin, Nathan Weizenbaum and Norman Clarke
|
44
|
+
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
46
|
+
this software and associated documentation files (the "Software"), to deal in
|
47
|
+
the Software without restriction, including without limitation the rights to
|
48
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
49
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
50
|
+
subject to the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be included in all
|
53
|
+
copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
56
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
57
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
58
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
59
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
60
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/html2haml/html.rb
CHANGED
@@ -369,8 +369,16 @@ module Haml
|
|
369
369
|
original_indent = content[/\A(\s*)/, 1]
|
370
370
|
if content.split("\n").all? {|l| l.strip.empty? || l =~ /^#{original_indent}/}
|
371
371
|
content.gsub!(/^#{original_indent}/, tabulate(tabs + 1))
|
372
|
+
else
|
373
|
+
# Indentation is inconsistent. Strip whitespace from start and indent all
|
374
|
+
# to ensure valid Haml.
|
375
|
+
content.lstrip!
|
376
|
+
content.gsub!(/^/, tabulate(tabs + 1))
|
372
377
|
end
|
373
378
|
|
379
|
+
content.rstrip!
|
380
|
+
content << "\n"
|
381
|
+
|
374
382
|
"#{tabulate(tabs)}:#{filter}\n#{content}"
|
375
383
|
end
|
376
384
|
|
data/lib/html2haml/html/erb.rb
CHANGED
data/lib/html2haml/version.rb
CHANGED
data/test/erb_test.rb
CHANGED
@@ -457,6 +457,15 @@ HAML
|
|
457
457
|
ERB
|
458
458
|
end
|
459
459
|
|
460
|
+
def test_can_parse_ruby_19_hashes_as_arguments
|
461
|
+
erb = "<%= foobar 'foo', {bar: 'baz'} %>"
|
462
|
+
begin
|
463
|
+
Haml::HTML::ERB.new(erb)
|
464
|
+
rescue
|
465
|
+
flunk "should not raise an error"
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
460
469
|
def test_should_wrap_in_silent
|
461
470
|
assert_equal(<<HTML.rstrip, Haml::HTML::ERB.new(<<ERB).src)
|
462
471
|
<haml:silent> some_variable_or_function \n</haml:silent>
|
data/test/html2haml_test.rb
CHANGED
@@ -237,6 +237,41 @@ HAML
|
|
237
237
|
HTML
|
238
238
|
end
|
239
239
|
|
240
|
+
def test_style_to_css_filter_with_following_content
|
241
|
+
assert_equal(<<HAML.rstrip, render(<<HTML))
|
242
|
+
%head
|
243
|
+
:css
|
244
|
+
foo {
|
245
|
+
bar: baz;
|
246
|
+
}
|
247
|
+
%body Hello
|
248
|
+
HAML
|
249
|
+
<head>
|
250
|
+
<style type="text/css">
|
251
|
+
foo {
|
252
|
+
bar: baz;
|
253
|
+
}
|
254
|
+
</style>
|
255
|
+
</head>
|
256
|
+
<body>Hello</body>
|
257
|
+
HTML
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_filter_with_inconsistent_indentation
|
261
|
+
assert_equal(<<HAML.rstrip, render(<<HTML))
|
262
|
+
:css
|
263
|
+
foo {
|
264
|
+
badly: indented;
|
265
|
+
}
|
266
|
+
HAML
|
267
|
+
<style type="text/css">
|
268
|
+
foo {
|
269
|
+
badly: indented;
|
270
|
+
}
|
271
|
+
</style>
|
272
|
+
HTML
|
273
|
+
end
|
274
|
+
|
240
275
|
def test_inline_conditional_comment
|
241
276
|
assert_equal(<<HAML.rstrip, render(<<HTML))
|
242
277
|
/[if foo] bar baz
|
metadata
CHANGED
@@ -1,138 +1,133 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: html2haml
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Norman Clarke
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2013-02-16 00:00:00 -03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: hpricot
|
16
|
-
|
17
|
-
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.8.6
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
25
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 8
|
30
|
+
- 6
|
27
31
|
version: 0.8.6
|
28
|
-
prerelease: false
|
29
32
|
type: :runtime
|
30
|
-
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
31
35
|
name: erubis
|
32
|
-
|
33
|
-
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 2.7.0
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
41
39
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 7
|
44
|
+
- 0
|
43
45
|
version: 2.7.0
|
44
|
-
prerelease: false
|
45
46
|
type: :runtime
|
46
|
-
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
47
49
|
name: ruby_parser
|
48
|
-
|
49
|
-
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 3.1.1
|
54
|
-
version_requirements: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
|
-
requirements:
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
57
53
|
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 3
|
57
|
+
- 1
|
58
|
+
- 1
|
59
59
|
version: 3.1.1
|
60
|
-
prerelease: false
|
61
60
|
type: :runtime
|
62
|
-
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
63
|
name: haml
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 4.0.0.rc.1
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
|
-
requirements:
|
73
|
-
- - ! '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 4.0.0.rc.1
|
76
64
|
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 4
|
71
|
+
- 0
|
72
|
+
- 0
|
73
|
+
- rc
|
74
|
+
- 1
|
75
|
+
version: 4.0.0.rc.1
|
77
76
|
type: :runtime
|
78
|
-
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
79
|
name: simplecov
|
80
|
-
|
81
|
-
|
82
|
-
requirements:
|
83
|
-
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 0.7.1
|
86
|
-
version_requirements: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
|
-
requirements:
|
80
|
+
prerelease: false
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
89
83
|
- - ~>
|
90
|
-
- !ruby/object:Gem::Version
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
- 7
|
88
|
+
- 1
|
91
89
|
version: 0.7.1
|
92
|
-
prerelease: false
|
93
90
|
type: :development
|
94
|
-
|
91
|
+
version_requirements: *id005
|
92
|
+
- !ruby/object:Gem::Dependency
|
95
93
|
name: minitest
|
96
|
-
|
97
|
-
|
98
|
-
requirements:
|
99
|
-
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: 4.4.0
|
102
|
-
version_requirements: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
|
-
requirements:
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
105
97
|
- - ~>
|
106
|
-
- !ruby/object:Gem::Version
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 4
|
101
|
+
- 4
|
102
|
+
- 0
|
107
103
|
version: 4.4.0
|
108
|
-
prerelease: false
|
109
104
|
type: :development
|
110
|
-
|
105
|
+
version_requirements: *id006
|
106
|
+
- !ruby/object:Gem::Dependency
|
111
107
|
name: rake
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
|
-
requirements:
|
121
|
-
- - ! '>='
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '0'
|
124
108
|
prerelease: false
|
109
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
125
116
|
type: :development
|
117
|
+
version_requirements: *id007
|
126
118
|
description: Converts HTML into Haml
|
127
|
-
email:
|
119
|
+
email:
|
128
120
|
- norman@njclarke.com
|
129
|
-
executables:
|
121
|
+
executables:
|
130
122
|
- html2haml
|
131
123
|
extensions: []
|
124
|
+
|
132
125
|
extra_rdoc_files: []
|
133
|
-
|
126
|
+
|
127
|
+
files:
|
134
128
|
- .gitignore
|
135
129
|
- .travis.yml
|
130
|
+
- Changelog.markdown
|
136
131
|
- Gemfile
|
137
132
|
- MIT-LICENSE
|
138
133
|
- README.md
|
@@ -147,37 +142,37 @@ files:
|
|
147
142
|
- test/erb_test.rb
|
148
143
|
- test/html2haml_test.rb
|
149
144
|
- test/test_helper.rb
|
145
|
+
has_rdoc: true
|
150
146
|
homepage: http://haml.info
|
151
147
|
licenses: []
|
148
|
+
|
152
149
|
post_install_message:
|
153
150
|
rdoc_options: []
|
154
|
-
|
151
|
+
|
152
|
+
require_paths:
|
155
153
|
- lib
|
156
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
segments:
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
segments:
|
162
159
|
- 0
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
segments:
|
160
|
+
version: "0"
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
segments:
|
171
166
|
- 0
|
172
|
-
|
173
|
-
version: '0'
|
167
|
+
version: "0"
|
174
168
|
requirements: []
|
169
|
+
|
175
170
|
rubyforge_project:
|
176
|
-
rubygems_version: 1.
|
171
|
+
rubygems_version: 1.3.6
|
177
172
|
signing_key:
|
178
173
|
specification_version: 3
|
179
174
|
summary: Converts HTML into Haml
|
180
|
-
test_files:
|
175
|
+
test_files:
|
181
176
|
- test/erb_test.rb
|
182
177
|
- test/html2haml_test.rb
|
183
178
|
- test/test_helper.rb
|