Skip to content

Commit

Permalink
@functions now starts in a new line
Browse files Browse the repository at this point in the history
  • Loading branch information
TwentyFourMinutes committed Oct 27, 2019
1 parent be1b19b commit 37cb76c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/RazorMinifier/RazorMinifier.Core/Minifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ internal static class Minifier
private static readonly Regex _simpleCommentRegex;
private static readonly Regex _multiLineCommentRegex;
private static readonly Regex _razorSectionRegex;
private static readonly Regex _razorFunctionsRegex;

static Minifier()
{
_emptyLineRegex = new Regex(@"(\n|\t|\s\s)");
_simpleCommentRegex = new Regex(@"(?<!:)\/\/.*");
_multiLineCommentRegex = new Regex(@"(<!--.*-->|\/\*.*\*\/)");
_razorSectionRegex = new Regex(@"@section\s\w+\s?{");
_razorFunctionsRegex = new Regex(@"@functions\s\w+\s?{");
}

public static string Minify(string input)
Expand Down Expand Up @@ -59,6 +61,11 @@ public static string Minify(string input)
input = input.Insert(match.Index, Environment.NewLine);
}

foreach (Match match in _razorFunctionsRegex.Matches(input))
{
input = input.Insert(match.Index, Environment.NewLine);
}

foreach (var header in headers)
{
input = string.Concat(header, Environment.NewLine, input);
Expand Down

0 comments on commit 37cb76c

Please sign in to comment.