diff --git a/pysass.cpp b/pysass.cpp index 03e53d99..89484b75 100644 --- a/pysass.cpp +++ b/pysass.cpp @@ -412,15 +412,15 @@ PySass_compile_string(PyObject *self, PyObject *args) { char *string, *include_paths; const char *error_message, *output_string; Sass_Output_Style output_style; - int source_comments, error_status, precision; + int source_comments, error_status, precision, indented; PyObject *custom_functions; PyObject *result; if (!PyArg_ParseTuple(args, - PySass_IF_PY3("yiiyiO", "siisiO"), + PySass_IF_PY3("yiiyiOi", "siisiOi"), &string, &output_style, &source_comments, &include_paths, &precision, - &custom_functions)) { + &custom_functions, &indented)) { return NULL; } @@ -430,6 +430,7 @@ PySass_compile_string(PyObject *self, PyObject *args) { sass_option_set_source_comments(options, source_comments); sass_option_set_include_path(options, include_paths); sass_option_set_precision(options, precision); + sass_option_set_is_indented_syntax_src(options, indented); _add_custom_functions(options, custom_functions); sass_compile_data_context(context); diff --git a/sass.py b/sass.py index 874f1904..bf2498fd 100644 --- a/sass.py +++ b/sass.py @@ -205,6 +205,9 @@ def compile(**kwargs): :type custom_functions: :class:`collections.Set`, :class:`collections.Sequence`, :class:`collections.Mapping` + :param indented: optional declaration that the string is SASS, not SCSS + formatted. :const:`False` by default + :type indented: :class:`bool` :returns: the compiled CSS string :rtype: :class:`str` :raises sass.CompileError: when it fails for any reason @@ -449,9 +452,13 @@ def func_name(a, b): string = kwargs.pop('string') if isinstance(string, text_type): string = string.encode('utf-8') + indented = kwargs.pop('indented', False) + if not isinstance(indented, bool): + raise TypeError('indented must be bool, not ' + + repr(source_comments)) s, v = compile_string( string, output_style, source_comments, include_paths, precision, - custom_functions, + custom_functions, indented ) if s: return v.decode('utf-8') diff --git a/sasstests.py b/sasstests.py index d00b16c1..3829e618 100644 --- a/sasstests.py +++ b/sasstests.py @@ -256,6 +256,11 @@ def test_compile_string(self): self.assertRaises(TypeError, sass.compile, string=1234) self.assertRaises(TypeError, sass.compile, string=[]) + def test_compile_string_sass_style(self): + actual = sass.compile(string='a\n\tb\n\t\tcolor: blue;', + indented=True) + assert actual == 'a b {\n color: blue; }\n' + def test_compile_string_deprecated_source_comments_line_numbers(self): source = '''a { b { color: blue; }