Skip to content

Commit d09c4b5

Browse files
committed
Options: Makes output linefeed adjustable.
* To make output readable in Notepad. 😄 * LibSass new API exposes this option via `sass_option_set_linefeed`. * This is a **non-breaking change** using additional property `OutputLineFeed` as opposed to altering the public `Compile` signature. * The default is set to `\r\n` as opposed to libsass default `\r`. * In user space, it will be adjustable as follow: ```c# var sassCompiler = new SassCompiler(); sassCompiler.OutputLineFeed = "\r"; Console.WriteLine(sassCompiler.CompileFile(@"C:\temp\blah.scss").CSS); ```
1 parent a37f2f6 commit d09c4b5

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

libsass/SassInterface.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace LibSassNet
3333
{
3434
char* includePaths = MarshalString(sassContext->Options->IncludePaths);
3535
char* sourceString = MarshalString(sassContext->SourceString);
36+
char* lineFeed = MarshalString(sassContext->Options->LineFeed);
3637
struct Sass_Data_Context* ctx;
3738

3839
try
@@ -45,6 +46,7 @@ namespace LibSassNet
4546
sass_option_set_output_style(options, GetOutputStyle(sassContext->Options->OutputStyle));
4647
sass_option_set_source_comments(options, sassContext->Options->IncludeSourceComments);
4748
sass_option_set_precision(options, sassContext->Options->Precision);
49+
sass_option_set_linefeed(options, lineFeed);
4850
sass_option_set_include_path(options, includePaths);
4951
sass_option_set_omit_source_map_url(options, true);
5052

@@ -88,8 +90,9 @@ namespace LibSassNet
8890
char* includePaths = MarshalString(sassFileContext->Options->IncludePaths);
8991
char* mapFile = MarshalString(sassFileContext->OutputSourceMapFile);
9092
char* inputPath = MarshalString(sassFileContext->InputPath);
91-
93+
char* lineFeed = MarshalString(sassFileContext->Options->LineFeed);
9294
struct Sass_File_Context* ctx;
95+
9396
try
9497
{
9598
ctx = sass_make_file_context(inputPath);
@@ -101,6 +104,7 @@ namespace LibSassNet
101104
sass_option_set_output_style(options, GetOutputStyle(sassFileContext->Options->OutputStyle));
102105
sass_option_set_source_comments(options, sassFileContext->Options->IncludeSourceComments);
103106
sass_option_set_precision(options, sassFileContext->Options->Precision);
107+
sass_option_set_linefeed(options, lineFeed);
104108
sass_option_set_include_path(options, includePaths);
105109
sass_option_set_omit_source_map_url(options, String::IsNullOrEmpty(sassFileContext->OutputSourceMapFile));
106110
sass_option_set_source_map_file(options, mapFile);

libsass/SassOptions.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace LibSassNet
3131
property bool IncludeSourceComments;
3232
property int Precision;
3333
property String^ IncludePaths;
34+
property String^ LineFeed;
3435
};
3536

3637
public ref class SassContext

libsassnet/SassCompiler.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class SassCompiler : ISassCompiler
2929
{
3030
private readonly ISassInterface _sassInterface;
3131

32+
public string OutputLineFeed { get; set; }
33+
3234
public SassCompiler()
3335
{
3436
_sassInterface = new SassInterface();
@@ -50,7 +52,8 @@ public string Compile(string source, OutputStyle outputStyle = OutputStyle.Neste
5052
OutputStyle = (int)outputStyle,
5153
IncludeSourceComments = includeSourceComments,
5254
IncludePaths = includePaths != null ? String.Join(";", includePaths) : String.Empty,
53-
Precision = precision
55+
Precision = precision,
56+
LineFeed = OutputLineFeed ?? (OutputLineFeed = "\r\n")
5457
}
5558
};
5659

@@ -83,7 +86,8 @@ public CompileFileResult CompileFile(string inputPath, OutputStyle outputStyle =
8386
OutputStyle = (int)outputStyle,
8487
IncludeSourceComments = includeSourceComments,
8588
IncludePaths = String.Join(";", includePaths),
86-
Precision = precision
89+
Precision = precision,
90+
LineFeed = OutputLineFeed ?? (OutputLineFeed = "\r\n")
8791
},
8892
OutputSourceMapFile = sourceMapPath
8993
};

0 commit comments

Comments
 (0)