Skip to content

Multiple single-line comments with quotes consumes too many tokens #130

Description

@AndreasHogstrom
  • Node Version: v8.11.3
  • NPM Version: 5.6.0
  • postcss Version: 7.0.3
  • postcss-less Version: master

LESS

// Don't give up
.selector {}
// Don't give in

Errors

  CssSyntaxError {
    column: 8,
    input: {
      column: 8,
      line: 3,
      source: `// Don't give up␊
        .selector {}␊
      // Don't give in`,
    },
    line: 3,
    message: '<css input>:3:8: Unknown word',
    name: 'CssSyntaxError',
    reason: 'Unknown word',
    source: `// Don't give up␊
      .selector {}␊
    // Don't give in`,
  }

Expected Behavior

AST with 1 comment node, 1 selector node and 1 comment node.

Actual Behavior

Due to the use of nextToken in the comment paring code, the tokenizer will assume that the two quote characters encapsulate a string.

First comment node includes too much:

// Don't give up
.selector {}
// Don'
bits = ["//", " ", "Don", "'t give up\n  .selector {}\n// Don'"]

And continued parsing results in an error.

How can we reproduce the behavior?

test('inline comment with quotes', (t) => {
  const less = `// Don't give up
  .selector {}
// Don't give in`;

  const root = parse(less);
  t.is(nodeToString(root), less);
});```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions