public void comment(String s) {
    if (inStartTag) {
      maybeWriteTopLevelAttributes();
      inStartTag = false;
      write(">");
      newline();
    }
    if (!inText)
      indent();
    write("<!--");
    int start = 0;
    level++;
    for (;;) {
      int i = s.indexOf('\n', start);
      if (i < 0) {
        if (start > 0) {
          newline();
          indent();
          write(s.substring(start));
          level--;
          newline();
          indent();
        }
        else {
          level--;
          if (s.length() != 0) {
            write(' ');
            write(s);
            if (s.charAt(s.length() - 1) != ' ')
              write(' ');
          }
        }
        break;
      }
      newline();
      indent();
      write(s.substring(start, i));
      start = i + 1;
    }
    write("-->");
    if (!inText)
      newline();
  }