From 1942cf48f32ef16a81a692f98035f66a199d2a69 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Sat, 2 Apr 2016 09:44:46 -0600 Subject: [PATCH 1/2] Add semicolons where they are missing so sass-convert does not error out --- SassBeautify.py | 19 +++++++++++++++++-- tests/test.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/SassBeautify.py b/SassBeautify.py index d26f30e..fd429d9 100644 --- a/SassBeautify.py +++ b/SassBeautify.py @@ -173,11 +173,24 @@ def insert_newline_between_capturing_parentheses(m): content = re.sub(re.compile('(;.*|}.*)(\n +//.*\n.+[{,])$', re.MULTILINE), insert_newline_between_capturing_parentheses, content) return content - + def use_single_quotes(self, content): content = content.replace('"', '\'') return content + def beautify_semicolons(self, content): + ''' + Appends a semicolon to the lines missing one + ''' + def remove_semicolon_from_end_of_comment(m): + return m.group(1) + m.group(2) + + content = re.sub(re.compile('(? Date: Mon, 4 Apr 2016 18:03:24 -0600 Subject: [PATCH 2/2] fix unit test --- tests/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test.py b/tests/test.py index 7056ea5..edf6360 100644 --- a/tests/test.py +++ b/tests/test.py @@ -237,7 +237,7 @@ def test_semicolons(self): """)) self.assertEqual(beautified, textwrap.dedent("""\ - + ; // @import '_common'; @import "_colors"; ; @@ -251,5 +251,5 @@ def test_semicolons(self): font-size: 2em;; margin: -3px 0 !important; }; - - """)) \ No newline at end of file + ; + ;""")) \ No newline at end of file