htmlbeautifier 1.2.1 → 1.3.0
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/bin/htmlbeautifier +6 -0
- data/lib/htmlbeautifier.rb +2 -0
- data/lib/htmlbeautifier/builder.rb +12 -4
- data/lib/htmlbeautifier/html_parser.rb +3 -3
- data/lib/htmlbeautifier/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 818d22d7f95ad8d6e04cd9873ac17c76b45e214a
|
4
|
+
data.tar.gz: 5969729a1fd18825c7ee8769570b06091afa9d1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58be67dccb5256cd6f0d9de0eab7be4e6d3654de867167859faa9d15d0e7721aeebd32b0fba89b6e81c5817b0d632536a8d6d32f6bb51568709b86c11636d29
|
7
|
+
data.tar.gz: a8e35db53495bf2b95bb11c6b605d17b3afbff46f321b7a35d3e2c1825b736cebddc15134c7e9930b1fb63dacb9807311c9c02cc049c5fc5896a29a96dfb16c4
|
data/bin/htmlbeautifier
CHANGED
@@ -50,6 +50,12 @@ END
|
|
50
50
|
) do |num|
|
51
51
|
options[:stop_on_errors] = num
|
52
52
|
end
|
53
|
+
opts.on(
|
54
|
+
"-b", "--keep-blank-lines NUMBER", Integer,
|
55
|
+
"Set number of consecutive blank lines"
|
56
|
+
) do |num|
|
57
|
+
options[:keep_blank_lines] = num
|
58
|
+
end
|
53
59
|
opts.on(
|
54
60
|
"-h", "--help",
|
55
61
|
"Display this help message and exit"
|
data/lib/htmlbeautifier.rb
CHANGED
@@ -15,6 +15,8 @@ module HtmlBeautifier
|
|
15
15
|
# is false, i.e. continue to process the rest of the document.
|
16
16
|
# initial_level - The entire output will be indented by this number of steps.
|
17
17
|
# Default is 0.
|
18
|
+
# keep_blank_lines - an integer for the number of consecutive empty lines
|
19
|
+
# to keep in output.
|
18
20
|
#
|
19
21
|
def self.beautify(html, options = {})
|
20
22
|
if options[:tab_stops]
|
@@ -6,7 +6,8 @@ module HtmlBeautifier
|
|
6
6
|
DEFAULT_OPTIONS = {
|
7
7
|
indent: " ",
|
8
8
|
initial_level: 0,
|
9
|
-
stop_on_errors: false
|
9
|
+
stop_on_errors: false,
|
10
|
+
keep_blank_lines: 0
|
10
11
|
}
|
11
12
|
|
12
13
|
def initialize(output, options = {})
|
@@ -14,6 +15,7 @@ module HtmlBeautifier
|
|
14
15
|
@tab = options[:indent]
|
15
16
|
@stop_on_errors = options[:stop_on_errors]
|
16
17
|
@level = options[:initial_level]
|
18
|
+
@keep_blank_lines = options[:keep_blank_lines]
|
17
19
|
@new_line = false
|
18
20
|
@empty = true
|
19
21
|
@ie_cc_levels = []
|
@@ -45,7 +47,7 @@ module HtmlBeautifier
|
|
45
47
|
@empty = false
|
46
48
|
end
|
47
49
|
|
48
|
-
def new_line
|
50
|
+
def new_line
|
49
51
|
@new_line = true
|
50
52
|
end
|
51
53
|
|
@@ -121,9 +123,15 @@ module HtmlBeautifier
|
|
121
123
|
indent
|
122
124
|
end
|
123
125
|
|
126
|
+
def new_lines(*content)
|
127
|
+
blank_lines = content.first.scan(%r{\n}).count - 1
|
128
|
+
blank_lines = [blank_lines, @keep_blank_lines].min
|
129
|
+
@output << "\n" * blank_lines
|
130
|
+
new_line
|
131
|
+
end
|
132
|
+
|
124
133
|
def text(t)
|
125
|
-
emit t
|
126
|
-
new_line if t.end_with?("\n")
|
134
|
+
emit t
|
127
135
|
end
|
128
136
|
end
|
129
137
|
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
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Battley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.5
|
91
|
+
rubygems_version: 2.4.5
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: HTML/ERB beautifier
|