sasstools / scss-tokenizer

A tokenzier for Sass' SCSS syntax
MIT License
24 stars 22 forks source link

Problem with comments and breakline #18

Closed renatocassino closed 6 years ago

renatocassino commented 6 years ago

Hello guys.

I'm using this lib and I found a bug. After all comments in scss, the tokenizer ignore the next breakline.

Example:

For this simple css:

.product {
  &__description {
    color: #F00;
    border: 1px solid #ccc;
  }

  div ul li {
    height: 20px;
  }

  /* Comment */
  &__title {
    &--active {
      color: #33dd33;
    }

    background: #f00;
  }
}

The word title appears in line 12, but the tokenizer showing line 11.

[
    // ..........
    ["newline", "\n", 10, 0],
    ["newline", "\n", 11, 0],
    ["space", "  "],
    ["startComment", "/*", 11, 4],
    ["space", " "],
    ["word", "Comment", 11, 123, 11, 129],
    ["space", " "],
    ["endComment", "*/", 11, 132], // <-- HERE END COMMENT IN LINE 11
    ["space", "  "], // <-- Space instead of newline
    ["word", "&__title", 11, 136, 11, 143], // <-- Line 11 again
    ["space", " "],
    ["{", "{", 11, 145],
        // ........
]
renatocassino commented 6 years ago

Pull request: https://github.com/sasstools/scss-tokenizer/pull/19