html-to-haml 0.0.5 → 0.0.6
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
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjJjNTU0ZWE2YTJkMTZmZjNlNTIzN2MwMTRhNmNjODkxNzAwYzk1YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTUzNTg5OTFhNmE3NDI3YTZiZTA1Zjg3MGQyYWI3MGExMWY3ZjJmNA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTZjZTdkNTlkODczYzE3OGQwOWJjOTA0NmExNDJkZjE2OTgzMTEwNTYzOTFl
|
10
|
+
YjljYWE3NmVkNzgwMDMxODE2NjA4YWM1ZmViZDg3OGJkYzM2NGE5MDBiNGZk
|
11
|
+
YjZiMjEwNTNkOWI5MDY5MDU1NjVlZDlmMjFlOTZhYjg3ZmNiMWU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTZiZGVmYzdiOTYwNjg3YmM5OGYwMTgyMzdmYjBhNmEzZjJkZDFhZjY3NDcz
|
14
|
+
NzQ1ZmY1N2VmYzMxODY3MGE4YzUwNGEyOTA5YTRhMDc1MmEzNGViNjFmY2Fh
|
15
|
+
ZjJkMTdmYTE5NDkxYmE2Y2JiMGE4ZjllM2Y5MGJlZGRjZDFjNDM=
|
@@ -9,6 +9,7 @@ module HtmlToHaml::Html
|
|
9
9
|
HAML_SYMBOL_REGEX = ">\s*(\/|-|=)"
|
10
10
|
ERB_LINE_REGEX = "\n\s*(-|=).*$"
|
11
11
|
CLOSING_HTML_REGEX = "<\/.*?>"
|
12
|
+
DOCTYPE_REGEX = "<!DOCTYPE.*?>"
|
12
13
|
# For self-closing html tags that aren't self-closing by default
|
13
14
|
SELF_CLOSING_HTML_REGEX = "\/>"
|
14
15
|
SELF_CLOSING_TAGS = %w(area base br col command embed hr img input keygen link meta param source track wbr)
|
@@ -26,10 +27,12 @@ module HtmlToHaml::Html
|
|
26
27
|
|
27
28
|
def convert
|
28
29
|
indentation_tracker = IndentationTracker.new(indentation_amount: HtmlToHaml::INDENTATION_AMOUNT)
|
29
|
-
haml = @html.gsub(/#{ERB_LINE_REGEX}|#{CLOSING_HTML_REGEX}|#{SELF_CLOSING_HTML_REGEX}|#{self_closing_tag_regex}|#{HAML_SYMBOL_REGEX}|<|>|\n/) do |matched_elem|
|
30
|
+
haml = @html.gsub(/#{DOCTYPE_REGEX}|#{ERB_LINE_REGEX}|#{CLOSING_HTML_REGEX}|#{SELF_CLOSING_HTML_REGEX}|#{self_closing_tag_regex}|#{HAML_SYMBOL_REGEX}|<|>|\n/) do |matched_elem|
|
30
31
|
adjust_indentation_level(html: matched_elem, indentation_tracker: indentation_tracker)
|
31
32
|
start_of_line = "\n#{indentation_tracker.indentation}"
|
32
33
|
case matched_elem
|
34
|
+
when /#{DOCTYPE_REGEX}/
|
35
|
+
"#{matched_elem}\n"
|
33
36
|
when /#{ERB_LINE_REGEX}/
|
34
37
|
"#{start_of_line}#{matched_elem[1..-1]}"
|
35
38
|
when /#{self_closing_tag_regex}/
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-to-haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Natasha Hull-Richter
|
@@ -10,9 +10,8 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
and html comments as well.
|
13
|
+
description: ! "This app takes in html and erb code and turns it into haml. It supports
|
14
|
+
script and style tags\n and html comments as well."
|
16
15
|
email: nhull-richter@pivotal.io
|
17
16
|
executables: []
|
18
17
|
extensions: []
|
@@ -46,17 +45,17 @@ require_paths:
|
|
46
45
|
- lib
|
47
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
47
|
requirements:
|
49
|
-
- -
|
48
|
+
- - ! '>='
|
50
49
|
- !ruby/object:Gem::Version
|
51
50
|
version: '2.0'
|
52
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
52
|
requirements:
|
54
|
-
- -
|
53
|
+
- - ! '>='
|
55
54
|
- !ruby/object:Gem::Version
|
56
55
|
version: '0'
|
57
56
|
requirements: []
|
58
57
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.5
|
58
|
+
rubygems_version: 2.4.5
|
60
59
|
signing_key:
|
61
60
|
specification_version: 4
|
62
61
|
summary: A program that turns html.erb code into haml code.
|