htmlbeautifier 1.4.1 → 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: 4ad32fe5c137d828c711e50642ff3b00af14e3b8cdf18105506c1149de2c6cde
4
- data.tar.gz: d42bcce139d8a3e9a96f73735fbb068044f1f43c8d9951c89cd642bf4e996bef
3
+ metadata.gz: fcd8d466ff4ebc3419c99968d8a82f617c9911c520a4623d649d72a821dcec5c
4
+ data.tar.gz: 28113c3062ebfcf3dd6cb5d30dfd551d658b6d3061e7127bfb50e5584266266c
5
5
  SHA512:
6
- metadata.gz: 89dc1309a74d24da1f91ec626e3a0291918c9e0ef64370d10893ee30c961bcb788efa2bc99fbdb89af96d643cf418333b6b5b6eb3ec3e54dfb164398d0cdf0b5
7
- data.tar.gz: accce8738133c66d40ddcbdc21aee322f7b68e2d9bcca81102fbecc680a5a3b021d8911587e31e0a1963f3cae166e2f436a76800feebde59da411d96cb5fe628
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,12 +101,9 @@ if ARGV.any?
101
101
  end
102
102
  end
103
103
  unless failures.empty?
104
- relative_paths = failures.map { |path|
105
- Pathname.new(path).relative_path_from Dir.pwd
106
- }
107
- $stderr.puts [
104
+ warn [
108
105
  "Lint failed - files would be modified:",
109
- *relative_paths
106
+ *failures
110
107
  ].join("\n")
111
108
  exit 1
112
109
  end
@@ -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
@@ -10,47 +10,48 @@ module HtmlBeautifier
10
10
  link | meta | param | source | track | wbr
11
11
  )}mix
12
12
  HTML_BLOCK_ELEMENTS = %r{(?:
13
- address | article | aside | audio | blockquote | canvas | dd | dir | div |
14
- dl | dt | fieldset | figcaption | figure | footer | form | h1 | h2 | h3 |
15
- h4 | h5 | h6 | header | hr | li | menu | noframes | noscript | ol | p |
16
- pre | section | table | tbody | td | tfoot | th | thead | tr | ul | video
13
+ address | article | aside | audio | blockquote | canvas | dd | details |
14
+ dir | div | dl | dt | fieldset | figcaption | figure | footer | form |
15
+ h1 | h2 | h3 | h4 | h5 | h6 | header | hr | li | menu | noframes |
16
+ noscript | ol | p | pre | section | table | tbody | td | tfoot | th |
17
+ thead | tr | ul | video
17
18
  )}mix
18
19
 
19
20
  MAPPINGS = [
20
21
  [%r{(<%-?=?)(.*?)(-?%>)}om,
21
- :embed],
22
+ :embed],
22
23
  [%r{<!--\[.*?\]>}om,
23
- :open_ie_cc],
24
+ :open_ie_cc],
24
25
  [%r{<!\[.*?\]-->}om,
25
- :close_ie_cc],
26
+ :close_ie_cc],
26
27
  [%r{<!--.*?-->}om,
27
- :standalone_element],
28
+ :standalone_element],
28
29
  [%r{<!.*?>}om,
29
- :standalone_element],
30
+ :standalone_element],
30
31
  [%r{(<script#{ELEMENT_CONTENT}>)(.*?)(</script>)}omi,
31
- :foreign_block],
32
+ :foreign_block],
32
33
  [%r{(<style#{ELEMENT_CONTENT}>)(.*?)(</style>)}omi,
33
- :foreign_block],
34
+ :foreign_block],
34
35
  [%r{(<pre#{ELEMENT_CONTENT}>)(.*?)(</pre>)}omi,
35
- :preformatted_block],
36
+ :preformatted_block],
36
37
  [%r{(<textarea#{ELEMENT_CONTENT}>)(.*?)(</textarea>)}omi,
37
- :preformatted_block],
38
+ :preformatted_block],
38
39
  [%r{<#{HTML_VOID_ELEMENTS}(?: #{ELEMENT_CONTENT})?/?>}om,
39
- :standalone_element],
40
+ :standalone_element],
40
41
  [%r{</#{HTML_BLOCK_ELEMENTS}>}om,
41
- :close_block_element],
42
+ :close_block_element],
42
43
  [%r{<#{HTML_BLOCK_ELEMENTS}(?: #{ELEMENT_CONTENT})?>}om,
43
- :open_block_element],
44
+ :open_block_element],
44
45
  [%r{</#{ELEMENT_CONTENT}>}om,
45
- :close_element],
46
+ :close_element],
46
47
  [%r{<#{ELEMENT_CONTENT}[^/]>}om,
47
- :open_element],
48
+ :open_element],
48
49
  [%r{<[\w\-]+(?: #{ELEMENT_CONTENT})?/>}om,
49
- :standalone_element],
50
+ :standalone_element],
50
51
  [%r{(\s*\r?\n\s*)+}om,
51
- :new_lines],
52
+ :new_lines],
52
53
  [%r{[^<\n]+},
53
- :text]
54
+ :text]
54
55
  ].freeze
55
56
 
56
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 = 1
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.1
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: 2021-12-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