htmlbeautifier 1.4.2 → 1.4.3

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: bd09d146c5469cdbf95c8d49a0e9b9a32d765d210a2b4c443a9d0845ab56affd
4
- data.tar.gz: c7746bcdc9b4952257db38632bed91ba40302cb85a946db3d609f511bb815a68
3
+ metadata.gz: fcd8d466ff4ebc3419c99968d8a82f617c9911c520a4623d649d72a821dcec5c
4
+ data.tar.gz: 28113c3062ebfcf3dd6cb5d30dfd551d658b6d3061e7127bfb50e5584266266c
5
5
  SHA512:
6
- metadata.gz: ebbb7b47f269a6a7a508372a65f9eb58b38d87aa2d986e3fb834d8c247503f0eafe651d9002d4b0e18f4de95dcd59bf056a633d10948a090b959e86f013cd79e
7
- data.tar.gz: 833b04c89b02eb0228442cfbf921201d4597bf9a1d994f346faf3333a0721935f68884ce6311f5b27ebad9aac79056500917f0c524119cf99f70d6b509b805fd
6
+ metadata.gz: 0c07ed38537750b35280e3131c9333f5c31deabff6da46f5a333557b8af5c261babda15f98a45f9ea9d8213f14368ad9b671fac38f61e7f7439a3d0edb2bb675
7
+ data.tar.gz: 76c39b1d92accd12e3b6c354b2214e0da149d7e400d0e66583b6505c498eadd8de79336abfcf90087d1ca9e56c00d6a0ec4b4f211da5924a7546fc65e1d84971
data/README.md CHANGED
@@ -23,13 +23,13 @@ Ideal for tidying up Rails templates.
23
23
  To update files in-place:
24
24
 
25
25
  ``` sh
26
- $ htmlbeautifier file1 [file2 ...]
26
+ $ htmlbeautifier file1.html.erb [file2.html.erb ...]
27
27
  ```
28
28
 
29
29
  or to operate on standard input and output:
30
30
 
31
31
  ``` sh
32
- $ htmlbeautifier < input > output
32
+ $ htmlbeautifier < untidy.html.erb > formatted.html.erb
33
33
  ```
34
34
 
35
35
  ### In your code
@@ -37,13 +37,13 @@ $ htmlbeautifier < input > output
37
37
  ```ruby
38
38
  require 'htmlbeautifier'
39
39
 
40
- beautiful = HtmlBeautifier.beautify(messy)
40
+ beautiful = HtmlBeautifier.beautify(untify_html_string)
41
41
  ```
42
42
 
43
43
  You can also specify how to indent (the default is two spaces):
44
44
 
45
45
  ```ruby
46
- beautiful = HtmlBeautifier.beautify(messy, indent: "\t")
46
+ beautiful = HtmlBeautifier.beautify(untidy_html_string, indent: "\t")
47
47
  ```
48
48
 
49
49
  ## Installation
data/bin/htmlbeautifier CHANGED
@@ -8,13 +8,13 @@ require "stringio"
8
8
 
9
9
  def beautify(name, input, output, options)
10
10
  output.puts HtmlBeautifier.beautify(input, options)
11
- rescue StandardError => e
11
+ rescue => e
12
12
  raise "Error parsing #{name}: #{e}"
13
13
  end
14
14
 
15
15
  executable = File.basename(__FILE__)
16
16
 
17
- options = { indent: " " }
17
+ options = {indent: " "}
18
18
  parser = OptionParser.new do |opts|
19
19
  opts.banner = "Usage: #{executable} [options] [file ...]"
20
20
  opts.separator <<~STRING
@@ -101,7 +101,7 @@ if ARGV.any?
101
101
  end
102
102
  end
103
103
  unless failures.empty?
104
- $stderr.puts [
104
+ warn [
105
105
  "Lint failed - files would be modified:",
106
106
  *failures
107
107
  ].join("\n")
@@ -25,7 +25,7 @@ module HtmlBeautifier
25
25
  @embedded_indenter = RubyIndenter.new
26
26
  end
27
27
 
28
- private
28
+ private
29
29
 
30
30
  def error(text)
31
31
  return unless @stop_on_errors
@@ -19,39 +19,39 @@ module HtmlBeautifier
19
19
 
20
20
  MAPPINGS = [
21
21
  [%r{(<%-?=?)(.*?)(-?%>)}om,
22
- :embed],
22
+ :embed],
23
23
  [%r{<!--\[.*?\]>}om,
24
- :open_ie_cc],
24
+ :open_ie_cc],
25
25
  [%r{<!\[.*?\]-->}om,
26
- :close_ie_cc],
26
+ :close_ie_cc],
27
27
  [%r{<!--.*?-->}om,
28
- :standalone_element],
28
+ :standalone_element],
29
29
  [%r{<!.*?>}om,
30
- :standalone_element],
30
+ :standalone_element],
31
31
  [%r{(<script#{ELEMENT_CONTENT}>)(.*?)(</script>)}omi,
32
- :foreign_block],
32
+ :foreign_block],
33
33
  [%r{(<style#{ELEMENT_CONTENT}>)(.*?)(</style>)}omi,
34
- :foreign_block],
34
+ :foreign_block],
35
35
  [%r{(<pre#{ELEMENT_CONTENT}>)(.*?)(</pre>)}omi,
36
- :preformatted_block],
36
+ :preformatted_block],
37
37
  [%r{(<textarea#{ELEMENT_CONTENT}>)(.*?)(</textarea>)}omi,
38
- :preformatted_block],
38
+ :preformatted_block],
39
39
  [%r{<#{HTML_VOID_ELEMENTS}(?: #{ELEMENT_CONTENT})?/?>}om,
40
- :standalone_element],
40
+ :standalone_element],
41
41
  [%r{</#{HTML_BLOCK_ELEMENTS}>}om,
42
- :close_block_element],
42
+ :close_block_element],
43
43
  [%r{<#{HTML_BLOCK_ELEMENTS}(?: #{ELEMENT_CONTENT})?>}om,
44
- :open_block_element],
44
+ :open_block_element],
45
45
  [%r{</#{ELEMENT_CONTENT}>}om,
46
- :close_element],
46
+ :close_element],
47
47
  [%r{<#{ELEMENT_CONTENT}[^/]>}om,
48
- :open_element],
48
+ :open_element],
49
49
  [%r{<[\w\-]+(?: #{ELEMENT_CONTENT})?/>}om,
50
- :standalone_element],
50
+ :standalone_element],
51
51
  [%r{(\s*\r?\n\s*)+}om,
52
- :new_lines],
52
+ :new_lines],
53
53
  [%r{[^<\n]+},
54
- :text]
54
+ :text]
55
55
  ].freeze
56
56
 
57
57
  def initialize
@@ -26,14 +26,14 @@ module HtmlBeautifier
26
26
  [source_so_far.chomp.split(%r{\n}).count, 1].max
27
27
  end
28
28
 
29
- private
29
+ private
30
30
 
31
31
  def dispatch(receiver)
32
32
  _, method = @maps.find { |pattern, _| @scanner.scan(pattern) }
33
33
  raise "Unmatched sequence" unless method
34
34
 
35
35
  receiver.__send__(method, *extract_params(@scanner))
36
- rescue StandardError => e
36
+ rescue => e
37
37
  raise "#{e.message} on line #{source_line_number}"
38
38
  end
39
39
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module HtmlBeautifier
4
4
  class RubyIndenter
5
- INDENT_KEYWORDS = %w[if elsif else unless while until begin for].freeze
6
- OUTDENT_KEYWORDS = %w[elsif else end].freeze
5
+ INDENT_KEYWORDS = %w[if elsif else unless while until begin for case when].freeze
6
+ OUTDENT_KEYWORDS = %w[elsif else end when].freeze
7
7
  RUBY_INDENT = %r{
8
8
  ^ ( #{INDENT_KEYWORDS.join("|")} )\b
9
9
  | \b ( do | \{ ) ( \s* \| [^|]+ \| )? $
@@ -4,7 +4,7 @@ module HtmlBeautifier # :nodoc:
4
4
  module VERSION # :nodoc:
5
5
  MAJOR = 1
6
6
  MINOR = 4
7
- TINY = 2
7
+ TINY = 3
8
8
 
9
9
  STRING = [MAJOR, MINOR, TINY].join(".")
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmlbeautifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Battley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-05 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rubocop
42
+ name: standard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1'
47
+ version: '1.33'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1'
54
+ version: '1.33'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.2.22
118
+ rubygems_version: 3.4.15
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: HTML/ERB beautifier