mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-27 04:34:59 +01:00
Fix /* formatting to match Ruby Sass
This commit is contained in:
parent
7454a1b57f
commit
b404e32c46
@ -5,6 +5,9 @@
|
||||
* Don't add an extra `*/` to comments in the indented syntax that already have
|
||||
it.
|
||||
|
||||
* Improve the formatting of comments that don't start on the same line as the
|
||||
opening `/*`.
|
||||
|
||||
## 1.0.0-beta.5.2
|
||||
|
||||
* Fix a bug where some colors would crash `compressed` mode.
|
||||
|
@ -48,6 +48,14 @@ abstract class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
/// Consumes spaces and tabs.
|
||||
@protected
|
||||
void spaces() {
|
||||
while (!scanner.isDone && isSpaceOrTab(scanner.peekChar())) {
|
||||
scanner.readChar();
|
||||
}
|
||||
}
|
||||
|
||||
/// Consumes and ignores a comment if possible.
|
||||
///
|
||||
/// Returns whether the comment was consumed.
|
||||
|
@ -208,7 +208,17 @@ class SassParser extends StylesheetParser {
|
||||
var buffer = new InterpolationBuffer()..write("/*");
|
||||
var parentIndentation = currentIndentation;
|
||||
while (true) {
|
||||
if (!first) {
|
||||
if (first) {
|
||||
// If the first line is empty, ignore it.
|
||||
var beginningOfComment = scanner.position;
|
||||
spaces();
|
||||
if (isNewline(scanner.peekChar())) {
|
||||
_readIndentation();
|
||||
buffer.writeCharCode($space);
|
||||
} else {
|
||||
buffer.write(scanner.substring(beginningOfComment));
|
||||
}
|
||||
} else {
|
||||
buffer.writeln();
|
||||
buffer.write(" * ");
|
||||
}
|
||||
|
@ -12,12 +12,15 @@ const _asciiCaseBit = 0x20;
|
||||
|
||||
/// Returns whether [character] is an ASCII whitespace character.
|
||||
bool isWhitespace(int character) =>
|
||||
character == $space || character == $tab || isNewline(character);
|
||||
isSpaceOrTab(character) || isNewline(character);
|
||||
|
||||
/// Returns whether [character] is an ASCII newline.
|
||||
bool isNewline(int character) =>
|
||||
character == $lf || character == $cr || character == $ff;
|
||||
|
||||
/// Returns whether [character] is a space or a tab character.
|
||||
bool isSpaceOrTab(int character) => character == $space || character == $tab;
|
||||
|
||||
/// Returns whether [character] is a letter or number.
|
||||
bool isAlphanumeric(int character) =>
|
||||
isAlphabetic(character) || isDigit(character);
|
||||
|
Loading…
Reference in New Issue
Block a user