hamlit 1.7.1 → 1.7.2
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/doc/engine/new_attribute.md +2 -2
- data/doc/engine/old_attributes.md +6 -6
- data/doc/faml/engine/old_attributes.md +3 -3
- data/doc/haml/engine/new_attribute.md +2 -2
- data/doc/haml/engine/old_attributes.md +4 -4
- data/lib/hamlit/parsers/attribute.rb +10 -2
- data/lib/hamlit/version.rb +1 -1
- data/spec/hamlit/engine/old_attributes_spec.rb +8 -0
- metadata +2 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97c6e8e207573918bcdc35f2d9c5092221906577
|
|
4
|
+
data.tar.gz: 466188f7c1a06f359f33b85406263b8fc697b77b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 324a94fe243be2497ef6d0ab786386b6f281d2ab990396863e90cdad800f815578c2228bf6df3f2a85de7034e3621394456f6b20235701c70538e3f90ebc9c42
|
|
7
|
+
data.tar.gz: c69e5ed58abd2d603b54cd4915ffc90c00242f6fa9225b6db7be726c6f7aec01a2a2348c267dd2b1c3f3c0a2cc87700350286a4deebd237845ed56dea2e83170
|
data/CHANGELOG.md
CHANGED
data/doc/engine/new_attribute.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
# [new\_attribute\_spec.rb:
|
|
26
|
+
# [new\_attribute\_spec.rb:47](/spec/hamlit/engine/new_attribute_spec.rb#L47)
|
|
27
27
|
## Input
|
|
28
28
|
```haml
|
|
29
29
|
%a(title="'")
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
# [new\_attribute\_spec.rb:
|
|
53
|
+
# [new\_attribute\_spec.rb:59](/spec/hamlit/engine/new_attribute_spec.rb#L59)
|
|
54
54
|
## Input
|
|
55
55
|
```haml
|
|
56
56
|
- title = "'\""
|
|
@@ -26,7 +26,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
# [old\_attributes\_spec.rb:
|
|
29
|
+
# [old\_attributes\_spec.rb:132](/spec/hamlit/engine/old_attributes_spec.rb#L132)
|
|
30
30
|
## Input
|
|
31
31
|
```haml
|
|
32
32
|
.foo{ class: ['bar'] }
|
|
@@ -56,7 +56,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
# [old\_attributes\_spec.rb:
|
|
59
|
+
# [old\_attributes\_spec.rb:211](/spec/hamlit/engine/old_attributes_spec.rb#L211)
|
|
60
60
|
## Input
|
|
61
61
|
```haml
|
|
62
62
|
/ wontfix: Non-boolean attributes are not escaped for optimization.
|
|
@@ -97,7 +97,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
# [old\_attributes\_spec.rb:
|
|
100
|
+
# [old\_attributes\_spec.rb:236](/spec/hamlit/engine/old_attributes_spec.rb#L236)
|
|
101
101
|
## Input
|
|
102
102
|
```haml
|
|
103
103
|
%a{title: "'"}
|
|
@@ -124,7 +124,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
# [old\_attributes\_spec.rb:
|
|
127
|
+
# [old\_attributes\_spec.rb:248](/spec/hamlit/engine/old_attributes_spec.rb#L248)
|
|
128
128
|
## Input
|
|
129
129
|
```haml
|
|
130
130
|
- title = "'\""
|
|
@@ -150,7 +150,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
# [old\_attributes\_spec.rb:
|
|
153
|
+
# [old\_attributes\_spec.rb:260](/spec/hamlit/engine/old_attributes_spec.rb#L260)
|
|
154
154
|
## Input
|
|
155
155
|
```haml
|
|
156
156
|
- title = { title: "'\"" }
|
|
@@ -176,7 +176,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
176
176
|
```
|
|
177
177
|
|
|
178
178
|
|
|
179
|
-
# [old\_attributes\_spec.rb:
|
|
179
|
+
# [old\_attributes\_spec.rb:283](/spec/hamlit/engine/old_attributes_spec.rb#L283)
|
|
180
180
|
## Input
|
|
181
181
|
```haml
|
|
182
182
|
%span{ data: { disable: true } } bar
|
|
@@ -18,7 +18,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
# [old\_attributes\_spec.rb:
|
|
21
|
+
# [old\_attributes\_spec.rb:132](/spec/hamlit/engine/old_attributes_spec.rb#L132)
|
|
22
22
|
## Input
|
|
23
23
|
```haml
|
|
24
24
|
.foo{ class: ['bar'] }
|
|
@@ -48,7 +48,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
# [old\_attributes\_spec.rb:
|
|
51
|
+
# [old\_attributes\_spec.rb:211](/spec/hamlit/engine/old_attributes_spec.rb#L211)
|
|
52
52
|
## Input
|
|
53
53
|
```haml
|
|
54
54
|
/ wontfix: Non-boolean attributes are not escaped for optimization.
|
|
@@ -89,7 +89,7 @@ Faml::Compiler::UnparsableRubyCode: Unparsable Ruby code is given to attributes:
|
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
# [old\_attributes\_spec.rb:
|
|
92
|
+
# [old\_attributes\_spec.rb:283](/spec/hamlit/engine/old_attributes_spec.rb#L283)
|
|
93
93
|
## Input
|
|
94
94
|
```haml
|
|
95
95
|
%span{ data: { disable: true } } bar
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
# [new\_attribute\_spec.rb:
|
|
26
|
+
# [new\_attribute\_spec.rb:47](/spec/hamlit/engine/new_attribute_spec.rb#L47)
|
|
27
27
|
## Input
|
|
28
28
|
```haml
|
|
29
29
|
%a(title="'")
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
# [new\_attribute\_spec.rb:
|
|
53
|
+
# [new\_attribute\_spec.rb:59](/spec/hamlit/engine/new_attribute_spec.rb#L59)
|
|
54
54
|
## Input
|
|
55
55
|
```haml
|
|
56
56
|
- title = "'\""
|
|
@@ -21,7 +21,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
# [old\_attributes\_spec.rb:
|
|
24
|
+
# [old\_attributes\_spec.rb:211](/spec/hamlit/engine/old_attributes_spec.rb#L211)
|
|
25
25
|
## Input
|
|
26
26
|
```haml
|
|
27
27
|
/ wontfix: Non-boolean attributes are not escaped for optimization.
|
|
@@ -62,7 +62,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
# [old\_attributes\_spec.rb:
|
|
65
|
+
# [old\_attributes\_spec.rb:236](/spec/hamlit/engine/old_attributes_spec.rb#L236)
|
|
66
66
|
## Input
|
|
67
67
|
```haml
|
|
68
68
|
%a{title: "'"}
|
|
@@ -89,7 +89,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
|
|
|
89
89
|
```
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
# [old\_attributes\_spec.rb:
|
|
92
|
+
# [old\_attributes\_spec.rb:248](/spec/hamlit/engine/old_attributes_spec.rb#L248)
|
|
93
93
|
## Input
|
|
94
94
|
```haml
|
|
95
95
|
- title = "'\""
|
|
@@ -115,7 +115,7 @@ Haml::SyntaxError: (haml):1: syntax error, unexpected tSTRING_DEND, expecting ')
|
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
# [old\_attributes\_spec.rb:
|
|
118
|
+
# [old\_attributes\_spec.rb:260](/spec/hamlit/engine/old_attributes_spec.rb#L260)
|
|
119
119
|
## Input
|
|
120
120
|
```haml
|
|
121
121
|
- title = { title: "'\"" }
|
|
@@ -29,12 +29,12 @@ module Hamlit
|
|
|
29
29
|
def parse_old_attributes(scanner)
|
|
30
30
|
return [] unless scanner.match?(/{/)
|
|
31
31
|
|
|
32
|
-
tokens =
|
|
32
|
+
tokens = try_lex(scanner.rest.sub(ATTRIBUTE_BEGIN, METHOD_CALL_PREFIX))
|
|
33
33
|
until balanced_embexprs_exist?(tokens, start_count: BALANCE_START_COUNT)
|
|
34
34
|
@current_lineno += 1
|
|
35
35
|
break unless @lines[@current_lineno]
|
|
36
36
|
scanner.concat(current_line)
|
|
37
|
-
tokens =
|
|
37
|
+
tokens = try_lex(scanner.rest.sub(ATTRIBUTE_BEGIN, METHOD_CALL_PREFIX))
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
tokens = fetch_balanced_embexprs(tokens, start_count: BALANCE_START_COUNT)
|
|
@@ -58,6 +58,14 @@ module Hamlit
|
|
|
58
58
|
scanner.pos += convert_position(text, *tokens.last.first) + 1
|
|
59
59
|
[text]
|
|
60
60
|
end
|
|
61
|
+
|
|
62
|
+
# Ripper.lex pulls invalid tokens first.
|
|
63
|
+
# This method rejects these invalid tokens.
|
|
64
|
+
def try_lex(str)
|
|
65
|
+
Ripper.lex(str).reject do |(row, col), type, str|
|
|
66
|
+
row == 0
|
|
67
|
+
end
|
|
68
|
+
end
|
|
61
69
|
end
|
|
62
70
|
end
|
|
63
71
|
end
|
data/lib/hamlit/version.rb
CHANGED
|
@@ -56,6 +56,14 @@ describe Hamlit::Engine do
|
|
|
56
56
|
HTML
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
it 'accepts tag content' do
|
|
60
|
+
assert_render(<<-'HAML', <<-HTML)
|
|
61
|
+
%span{ class: 'foo' } <b>bar</b>
|
|
62
|
+
HAML
|
|
63
|
+
<span class='foo'><b>bar</b></span>
|
|
64
|
+
HTML
|
|
65
|
+
end
|
|
66
|
+
|
|
59
67
|
it 'renders multi-byte chars as static attribute value' do
|
|
60
68
|
assert_render(<<-'HAML', <<-HTML)
|
|
61
69
|
%img{ alt: 'こんにちは' }
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hamlit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.
|
|
4
|
+
version: 1.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Takashi Kokubun
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-07-
|
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: escape_utils
|
|
@@ -626,4 +626,3 @@ test_files:
|
|
|
626
626
|
- spec/spec_helper/document_generator.rb
|
|
627
627
|
- spec/spec_helper/render_helper.rb
|
|
628
628
|
- spec/spec_helper/test_case.rb
|
|
629
|
-
has_rdoc:
|