src/lib/Parser.js
/**
  Consumes a comment if possible.

  @returns {boolean}
    Whether a comment was consumed.

  @see https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Comment
  */
Consumes a comment if possible.
Consumes a comment if possible .
consumeComment() {
    let { scanner } = this;
    if (!scanner.consumeStringFast('<!--')) {
      return false;
    }
    let content = scanner.consumeUntilString('--');
    this.validateChars(content);
    if (!scanner.consumeStringFast('-->')) {
      if (scanner.peek(2) === '--') {
        this.error("The string `--` isn't allowed inside a comment");
      } else {
        this.error('Unclosed comment');
      }
    }
    if (this.options.preserveComments) {
      this.addNode(new XmlComment(content.trim()));
    }
    return true;
  }
consumeComment ( ) { let { scanner } = this ; if ( ! scanner . consumeStringFast ( '<!--' ) ) { return false ; } let content = scanner . consumeUntilString ( '--' ) ; this . validateChars ( content ) ; if ( ! scanner . consumeStringFast ( '-->' ) ) { if ( scanner . peek ( 2 ) === '--' ) { this . error ( "The string `--` isn't allowed inside a comment" ) ; } else { this . error ( 'Unclosed comment' ) ; } } if ( this . options . preserveComments ) { this . addNode ( new XmlComment ( content . trim ( ) ) ) ; } return true ; }
Consumes a comment if possible.
Consumes a comment if possible .