webcode-tk 1.0.8__tar.gz → 1.0.9__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webcode-tk
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary:
5
5
  Home-page: https://github.com/HundredVisionsGuy/webcode-tk
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "webcode-tk"
3
- version = "1.0.8"
3
+ version = "1.0.9"
4
4
  description = ""
5
5
  authors = ["hundredvisionsguy <cwinikka@gmail.com>"]
6
6
  keywords = ["html", "validation", "css", ]
@@ -18,4 +18,4 @@ Modules exported by this package:
18
18
  - `validator_tools`: sends HTML or CSS code to the W3C Validator to check
19
19
  for errors.
20
20
  """
21
- __version__ = "1.0.8"
21
+ __version__ = "1.0.9"
@@ -93,6 +93,7 @@ class Stylesheet:
93
93
  self.type = stylesheet_type
94
94
  self.href = href
95
95
  self.text = text
96
+ self.__clean_text()
96
97
  self.nested_at_rules = []
97
98
  self.rulesets = []
98
99
  self.comments = []
@@ -108,6 +109,30 @@ class Stylesheet:
108
109
  self.__extract_rulesets()
109
110
  self.__set_selectors()
110
111
 
112
+ def __clean_text(self):
113
+ """cleans up CSS like removing extra line returns
114
+
115
+ This is here because if a student has more than 2 blank lines, it
116
+ could trigger an attribute error (at least it did in the past)
117
+ """
118
+ text_to_clean = self.text
119
+ split_text = text_to_clean.split("\n")
120
+ cleaned_text = ""
121
+ consecutive_blanks = 0
122
+ for line in split_text:
123
+ if not line:
124
+ consecutive_blanks += 1
125
+ if consecutive_blanks > 1:
126
+ consecutive_blanks = 1
127
+ continue
128
+ else:
129
+ if not line and cleaned_text:
130
+ cleaned_text += "\n"
131
+ cleaned_text += line + "\n"
132
+ if cleaned_text[-1:] == "\n":
133
+ cleaned_text = cleaned_text[:-1].strip()
134
+ self.text = cleaned_text
135
+
111
136
  def __minify(self):
112
137
  """Removes all whitespace, line returns, and tabs from text."""
113
138
  self.text = minify_code(self.text)
File without changes
File without changes