w_syntax_tree-erb 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +1 -1
- data/lib/syntax_tree/erb/parser.rb +13 -5
- data/lib/syntax_tree/erb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a76706871104d4d2ea966b498103883d197378ec7e93fb339430b82d8e70d7ee
|
4
|
+
data.tar.gz: 2d78160b39db8ddf8a62aaa132c3d935870d5db8f2383250a0502d7475d1bd1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111165a4191e3dd16baf66ef3ab1b1607a4ea1303113a63b5bf01a49d6b0ff0949ff313fb3ba6ada0e42a04de7809294738dc6b079537590915b3b764ac4b030
|
7
|
+
data.tar.gz: 8ff9ea2143768e7eb7ee067688b4ed1b33f05412f8bf381782376586edc7d958f3f53c4c28042320f583408f0775bee00ecedda7df8c145598b874cf8bcf2046
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.10.1] - 2023-08-20
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Allow `DOCTYPE` to be after other tags, to work with e.g. ERB-tags on first line.
|
14
|
+
|
9
15
|
## [0.10.0] - 2023-08-20
|
10
16
|
|
11
17
|
- Changes how whitespace and newlines are handled.
|
@@ -70,7 +76,8 @@ Output:
|
|
70
76
|
- Can format a lot of .html.erb-syntax and works as a plugin to syntax_tree.
|
71
77
|
- This is still early and there are a lot of different weird syntaxes out there.
|
72
78
|
|
73
|
-
[unreleased]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.
|
79
|
+
[unreleased]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.1...HEAD
|
80
|
+
[0.10.1]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.10.0...v0.10.1
|
74
81
|
[0.10.0]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.9.5...v0.10.0
|
75
82
|
[0.9.5]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.9.4...v0.9.5
|
76
83
|
[0.9.4]: https://github.com/davidwessman/syntax_tree-erb/compare/v0.9.3...v0.9.4
|
data/Gemfile.lock
CHANGED
@@ -20,16 +20,16 @@ module SyntaxTree
|
|
20
20
|
def initialize(source)
|
21
21
|
@source = source
|
22
22
|
@tokens = make_tokens
|
23
|
+
@found_doctype = false
|
23
24
|
end
|
24
25
|
|
25
26
|
def parse
|
26
|
-
doctype = maybe { parse_doctype }
|
27
27
|
elements = many { parse_any_tag }
|
28
28
|
|
29
29
|
location =
|
30
30
|
elements.first.location.to(elements.last.location) if elements.any?
|
31
31
|
|
32
|
-
Document.new(elements:
|
32
|
+
Document.new(elements: elements, location: location)
|
33
33
|
end
|
34
34
|
|
35
35
|
def debug_tokens
|
@@ -44,11 +44,19 @@ module SyntaxTree
|
|
44
44
|
loop do
|
45
45
|
tag =
|
46
46
|
atleast do
|
47
|
-
maybe {
|
48
|
-
maybe {
|
49
|
-
maybe {
|
47
|
+
maybe { parse_doctype } || maybe { parse_html_comment } ||
|
48
|
+
maybe { parse_erb_tag } || maybe { parse_erb_comment } ||
|
49
|
+
maybe { parse_html_element } || maybe { parse_new_line } ||
|
50
|
+
maybe { parse_chardata }
|
50
51
|
end
|
51
52
|
|
53
|
+
if tag.is_a?(Doctype)
|
54
|
+
if @found_doctype
|
55
|
+
raise(ParseError, "Only one doctype element is allowed")
|
56
|
+
else
|
57
|
+
@found_doctype = true
|
58
|
+
end
|
59
|
+
end
|
52
60
|
# Allow skipping empty CharData
|
53
61
|
return tag unless tag.skip?
|
54
62
|
end
|