Install-Package SoftCircuits.JavaScriptFormatter
SoftCircuits.JavaScriptFormatter is a JavaScript formatter library for .NET. It may be particularly useful for converting minified JavaScript to make it more readable.
To format a JavaScript string, declare an instance of the JavaScriptFormatter class and call the Format() method.
JavaScriptFormatter formatter = new JavaScriptFormatter();
string result = formatter.Format(javascript);To customize the behavior of this class, the constructor can optionally accept an instance of the FormatOptions class. This class contains the following members.
| Member | Meaning |
|---|---|
string Tab |
Specifies the string used for each indentation. Set to 4 spaces by default. |
bool NewLineBetweenFunctions |
Specifies if an empty line is inserted between functions. Set to true by default. |
bool OpenBraceOnNewLine |
Specifies if opening braces go on a new line. Set to false by default. |
bool NewLineBeforeLineComment |
Specifies if line comments go on new line. Set to true by default. |
bool NewLineBeforeInlineComment |
Specifies if inline comments go on a new line. Set to true by default. |
bool NewLineAfterInlineComment |
Specifies if a new line should follow inline comments. Set to true by default |