w_syntax_tree-erb 0.10.5 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d75bcbb66fc50b3559fa73a7ecb906aaa208a16bf041ae95793aed008bdd60f6
4
- data.tar.gz: d2f882155d6e2ab774de0367586926c853a367c55123f7bc05edebebbba9fe6d
3
+ metadata.gz: 459993e3b6d5a09ea5a902d6038acac34eeaddb7fa878cbd41a40039712c2d9a
4
+ data.tar.gz: 48843275b9b5ab46a23d61677c9e7b8cd93e7e4f5095376d128d9f525408cae9
5
5
  SHA512:
6
- metadata.gz: d7e9cc9b0c675244216ffd52db0751ee59b6ba79af00cb2b56ff955e351aa51c5a5d25d2737084283fa00707d51f4fb38fb7b6bbddf0c6bcc9f2831afd1fe9e1
7
- data.tar.gz: 2cd81b89e3ebdd1b1010f7c7509c9ef9a81eacf30d2285c34c36d3a97b7e86cb8d7d4f460ea3a7ba2ad1dd333b2e2e6a709056d328ff373b8692218701892d57
6
+ metadata.gz: 373abd1743f157914a3394f127a9e6b7d5c15fce3179894f74de072a220e5a6458fb2d09a25f4b7a2b5764c0f81f870045cba6c6f6756931be8fdbbb23e260eb
7
+ data.tar.gz: 38d635a29da6044441e6304fd488e8281b6a1ffa0718cea508541c242a9fc9d53d618956185ed1cf8cbf16efa357368ee99c5fb8d6d99a00e212e23eb92ac8a5
@@ -16,6 +16,7 @@ jobs:
16
16
  - "3.0"
17
17
  - "3.1"
18
18
  - "3.2"
19
+ - "3.3"
19
20
  name: CI
20
21
  runs-on: ubuntu-latest
21
22
  env:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ 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.11.0] - 2024-04-23
10
+
11
+ - ErbContent now has its value as child_nodes instead of empty array.
12
+ - Allow html void tags and format self-closing tags
13
+
9
14
  ## [0.10.5] - 2023-09-03
10
15
 
11
16
  - Handle ERB-tags inside HTML-tags, like `<div <%= "class='foo'" %>>`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- w_syntax_tree-erb (0.10.5)
4
+ w_syntax_tree-erb (0.11.0)
5
5
  prettier_print (~> 1.2, >= 1.2.0)
6
6
  syntax_tree (~> 6.1, >= 6.1.1)
7
7
 
@@ -9,20 +9,21 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  docile (1.4.0)
12
- minitest (5.19.0)
12
+ minitest (5.20.0)
13
13
  prettier_print (1.2.1)
14
- rake (13.0.6)
14
+ rake (13.1.0)
15
15
  simplecov (0.22.0)
16
16
  docile (~> 1.1)
17
17
  simplecov-html (~> 0.11)
18
18
  simplecov_json_formatter (~> 0.1)
19
19
  simplecov-html (0.12.3)
20
20
  simplecov_json_formatter (0.1.4)
21
- syntax_tree (6.1.1)
21
+ syntax_tree (6.2.0)
22
22
  prettier_print (>= 1.2.0)
23
23
 
24
24
  PLATFORMS
25
25
  arm64-darwin-21
26
+ arm64-darwin-23
26
27
  x86_64-darwin-21
27
28
  x86_64-darwin-22
28
29
  x86_64-linux
data/README.md CHANGED
@@ -79,6 +79,12 @@ puts failures
79
79
 
80
80
  ## Development
81
81
 
82
+ Install `husky`:
83
+
84
+ ```sh
85
+ npm i -g husky
86
+ ```
87
+
82
88
  Setup linting:
83
89
 
84
90
  ```sh
@@ -203,6 +203,10 @@ module SyntaxTree
203
203
  q.text(" ")
204
204
  end
205
205
 
206
+ # If element is a valid void element, but not currently self-closing
207
+ # format to be self-closing
208
+ q.text(" /") if node.is_void_element? and node.closing.value == ">"
209
+
206
210
  visit(node.closing)
207
211
  end
208
212
  end
@@ -185,6 +185,25 @@ module SyntaxTree
185
185
  # potentially contain an opening tag that self-closes, in which case the
186
186
  # content and closing tag will be nil.
187
187
  class HtmlNode < Block
188
+ # These elements do not require a closing tag
189
+ # https://developer.mozilla.org/en-US/docs/Glossary/Void_element
190
+ HTML_VOID_ELEMENTS = %w[
191
+ area
192
+ base
193
+ br
194
+ col
195
+ embed
196
+ hr
197
+ img
198
+ input
199
+ link
200
+ meta
201
+ param
202
+ source
203
+ track
204
+ wbr
205
+ ]
206
+
188
207
  # The opening tag of an element. It contains the opening character (<),
189
208
  # the name of the element, any optional attributes, and the closing
190
209
  # token (either > or />).
@@ -214,6 +233,10 @@ module SyntaxTree
214
233
  [opening, name, *attributes, closing]
215
234
  end
216
235
 
236
+ def is_void_element?
237
+ HTML_VOID_ELEMENTS.include?(name.value)
238
+ end
239
+
217
240
  alias deconstruct child_nodes
218
241
 
219
242
  def deconstruct_keys(keys)
@@ -253,6 +276,10 @@ module SyntaxTree
253
276
  end
254
277
  end
255
278
 
279
+ def is_void_element?
280
+ false
281
+ end
282
+
256
283
  def without_new_line
257
284
  self.class.new(
258
285
  **deconstruct_keys([]).merge(
@@ -481,7 +508,7 @@ module SyntaxTree
481
508
  end
482
509
 
483
510
  def child_nodes
484
- []
511
+ [@value].compact
485
512
  end
486
513
 
487
514
  alias deconstruct child_nodes
@@ -419,7 +419,11 @@ module SyntaxTree
419
419
  def parse_html_element
420
420
  opening = parse_html_opening_tag
421
421
 
422
- if opening.closing.value == ">"
422
+ if opening.closing.value == "/>"
423
+ HtmlNode.new(opening: opening, location: opening.location)
424
+ elsif opening.is_void_element?
425
+ HtmlNode.new(opening: opening, location: opening.location)
426
+ else
423
427
  elements = many { parse_any_tag }
424
428
  closing = maybe { parse_html_closing }
425
429
 
@@ -443,8 +447,6 @@ module SyntaxTree
443
447
  closing: closing,
444
448
  location: opening.location.to(closing.location)
445
449
  )
446
- else
447
- HtmlNode.new(opening: opening, location: opening.location)
448
450
  end
449
451
  end
450
452
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SyntaxTree
4
4
  module ERB
5
- VERSION = "0.10.5"
5
+ VERSION = "0.11.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: w_syntax_tree-erb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Newton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-09-03 00:00:00.000000000 Z
12
+ date: 2024-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prettier_print
@@ -118,7 +118,6 @@ files:
118
118
  - ".github/ISSUE_TEMPLATE/formatting-report.md"
119
119
  - ".github/ISSUE_TEMPLATE/general.md"
120
120
  - ".github/dependabot.yml"
121
- - ".github/workflows/auto-merge.yml"
122
121
  - ".github/workflows/main.yml"
123
122
  - ".gitignore"
124
123
  - ".husky/pre-commit"
@@ -1,22 +0,0 @@
1
- name: Dependabot auto-merge
2
- on: pull_request
3
-
4
- permissions:
5
- contents: write
6
- pull-requests: write
7
-
8
- jobs:
9
- dependabot:
10
- runs-on: ubuntu-latest
11
- if: ${{ github.actor == 'dependabot[bot]' }}
12
- steps:
13
- - name: Dependabot metadata
14
- id: metadata
15
- uses: dependabot/fetch-metadata@v1.3.3
16
- with:
17
- github-token: "${{ secrets.GITHUB_TOKEN }}"
18
- - name: Enable auto-merge for Dependabot PRs
19
- run: gh pr merge --auto --merge "$PR_URL"
20
- env:
21
- PR_URL: ${{github.event.pull_request.html_url}}
22
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}