How to use the postcss/lib/comment function in postcss

To help you get started, we’ve selected a few postcss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecomfe / node-lesslint / src / parser / index.js View on Github external
comment(token) {
        if (token[6] === 'inline') {
            let node = new Comment();
            this.init(node, token[2], token[3]);
            node.raws.inline = true;
            node.source.end = {line: token[4], column: token[5]};

            let text = token[1].slice(2);
            if (/^\s*$/.test(text)) {
                node.text = '';
                node.raws.left = text;
                node.raws.right = '';
            }
            else {
                let match = text.match(/^(\s*)([^]*[^\s])(\s*)$/);
                node.text = match[2];
                node.raws.left = match[1];
                node.raws.right = match[3];
            }
github postcss / sugarss / parser.es6 View on Github external
comment (part) {
    let token = part.tokens[0]
    let node = new Comment()
    this.init(node, part)
    node.source.end = { line: token[4], column: token[5] }
    this.commentText(node, token)
  }
github shellscape / postcss-less / lib / less-parser.js View on Github external
comment (token) {
    const node = new Comment();
    const content = token[1];
    const text = content.slice(2).replace(blockCommentEndPattern, '');

    this.init(node, token[2], token[3]);
    node.source.end = {
      line: token[4],
      column: token[5]
    };

    node.raws.content = content;
    node.raws.begin = content[0] + content[1];
    node.inline = token[6] === 'inline';
    node.block = !node.inline;

    if (/^\s*$/.test(text)) {
      node.text = '';
github postcss / sugarss / parser.es6 View on Github external
node.prop = prop

    let next = this.parts[this.pos + 1]

    while (!next.end && !next.atrule && !next.colon &&
                next.indent.length > part.indent.length) {
      value.push(['space', next.before + next.indent])
      value = value.concat(next.tokens)
      this.pos += 1
      next = this.parts[this.pos + 1]
    }

    let last = value[value.length - 1]
    if (last && last[0] === 'comment') {
      value.pop()
      let comment = new Comment()
      this.current.push(comment)
      comment.source = {
        input: this.input,
        start: { line: last[2], column: last[3] },
        end: { line: last[4], column: last[5] }
      }
      let prev = value[value.length - 1]
      if (prev && prev[0] === 'space') {
        value.pop()
        comment.raws.before = prev[1]
      }
      this.commentText(comment, last)
    }

    for (let i = value.length - 1; i > 0; i--) {
      let t = value[i][0]