erb-formatter 0.2.1 → 0.2.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/lib/erb/formatter.rb +6 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b90b39bdcbed3837f51229bc9c840b0bd44d61fa48eace4e2c7b32aedcb90e3c
|
4
|
+
data.tar.gz: d42ecb4464e92ceb46b9d266647db19c88540b369acb8585bec5800b4f0d6617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e7ba4c9ad276e45a2ad557000fe565ed66bc9205a7aabaf432d5a99dd693758c73a7975fbe0a770fe0becd9f66be294d0f2bf168b1249b3fd4d416e20770611
|
7
|
+
data.tar.gz: 0fed7945792aa4ad161c6b784796703c00b0aef7c69c61f4d77d4cfedbfae71ee76b1d2b7eeb106e6f3ec633031878dff5fd033605d7e61e0875ce1a3902b30d
|
data/lib/erb/formatter.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
|
3
|
-
# @debug = true
|
4
3
|
require "erb"
|
5
|
-
require "cgi"
|
6
4
|
require "ripper"
|
7
5
|
require 'securerandom'
|
8
6
|
require 'strscan'
|
9
|
-
require 'pp'
|
10
7
|
require 'stringio'
|
11
8
|
|
12
9
|
class ERB::Formatter
|
13
|
-
VERSION = "0.2.
|
10
|
+
VERSION = "0.2.2"
|
14
11
|
autoload :IgnoreList, 'erb/formatter/ignore_list'
|
15
12
|
|
16
13
|
class Error < StandardError; end
|
@@ -31,9 +28,11 @@ class ERB::Formatter
|
|
31
28
|
ERB_END = %r{(<%-?)\s*(end)\s*(-?%>)}
|
32
29
|
ERB_ELSE = %r{(<%-?)\s*(else|elsif\b.*)\s*(-?%>)}
|
33
30
|
|
31
|
+
TAG_NAME = /[a-z0-9_:-]+/
|
32
|
+
TAG_NAME_ONLY = /\A#{TAG_NAME}\z/
|
34
33
|
HTML_ATTR = %r{\s+#{SINGLE_QUOTE_ATTR}|\s+#{DOUBLE_QUOTE_ATTR}|\s+#{UNQUOTED_ATTR}|\s+#{ATTR_NAME}}m
|
35
|
-
HTML_TAG_OPEN = %r{<(
|
36
|
-
HTML_TAG_CLOSE = %r{</\s*(
|
34
|
+
HTML_TAG_OPEN = %r{<(#{TAG_NAME})((?:#{HTML_ATTR})*)(\s*?)(/>|>)}m
|
35
|
+
HTML_TAG_CLOSE = %r{</\s*(#{TAG_NAME})\s*>}
|
37
36
|
|
38
37
|
SELF_CLOSING_TAG = /\A(area|base|br|col|command|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)\z/i
|
39
38
|
|
@@ -355,7 +354,7 @@ class ERB::Formatter
|
|
355
354
|
elsif matched.match(HTML_TAG_OPEN)
|
356
355
|
_, tag_name, tag_attrs, _, tag_closing = *scanner.captures
|
357
356
|
|
358
|
-
raise "Unknown tag #{tag_name.inspect}" unless tag_name.match?(
|
357
|
+
raise "Unknown tag #{tag_name.inspect}" unless tag_name.match?(TAG_NAME_ONLY)
|
359
358
|
|
360
359
|
tag_self_closing = tag_closing == '/>' || SELF_CLOSING_TAG.match?(tag_name)
|
361
360
|
tag_attrs.strip!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erb-formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rufo
|