Render the comment as an HTML String.

@param comment the comment to render (may be {@code null} in which case an empty string is returned)
@return the HTML String representation of the comment
424386
public String format(Comment comment) {
        if (comment == null) {
            return "";
        }

        StringBuilder sb = new StringBuilder();

        for (CommentElement e : comment) {
            if (e instanceof CommentText) {
                sb.append(renderText((CommentText) e));

            } else if (e instanceof InlineLink) {
                sb.append(renderLink((InlineLink) e));
    
            } else if (e instanceof InlineValue) {
                sb.append(renderValue((InlineValue) e));
    
            } else if (e instanceof InlineTag) {
                sb.append(renderTag((InlineTag) e));

            } else {
                sb.append(renderUnrecognized(e));
            }
        }

        return sb.toString();
    }
1359752
public String format(String comment, int indentLevel, CommentLocation commentLocation) {

        // Return if there's nothing to do
        if (comment == null) {
            return null;
        }

        final StringBuilder indentString = new StringBuilder();
        for (int i = 0; i < indentLevel; i++) {
            indentString.append("    ");
        }

        // Comment ends with newline
        boolean endsWithNewline = (comment.endsWith("\r\n") || comment.endsWith("\n"));

        List<String> matchList = new ArrayList<String>();
        Matcher regexMatcher = commentFormattingRegex.matcher(comment);
        while (regexMatcher.find()) {
            matchList.add(regexMatcher.group());
        }

        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < matchList.size(); i++) {

            String indent;
            String newline;

            if (commentLocation.equals(CommentLocation.END)) {
                indent = " ";
                newline = "";
            } else {
                indent = indentString.toString();
                newline = "\n";
            }

            // We need to handle the last newline
            if (i == 0) {
                builder.append(indent + matchList.get(i).trim() + newline);
            } else if (i == matchList.size() - 1) {
                builder.append(indent + " " + matchList.get(i).trim() + (endsWithNewline ? newline : ""));
            } else {
                builder.append(indent + " " + matchList.get(i).trim() + newline);
            }
        }

        return builder.toString();
    }
56592
@Deprecated
  public boolean addComment(Comment comment) {
    if (getComments() != null) {
      return getComments().addData(comment);
    }
    return false;
  }
927822
public static StringBuffer appendComment(StringBuffer buffer, String comment)
	{
		StringBuffer _buffer = initStringBufferIfNecessary(buffer);
		return doAppendComment(_buffer, comment);
	}
1027339
public static String stripMultiLineComments(String text) {
        if (text == null) {
            return null;
        }

        try {
            StringBuffer output = new StringBuffer();

            // Comment rules:
            /*/           This is still a comment
            /* /* */      // Comments do not nest
            // /* */      This is in a comment
            /* // */      // The second // is needed to make this a comment.

            // First we strip multi line comments. I think this is important:
            boolean inMultiLine = false;
            BufferedReader in = new BufferedReader(new StringReader(text));
            while (true) {
                String line = in.readLine();
                if (line == null) {
                    break;
                }

                if (!inMultiLine) {
                    // We are not in a multi-line comment, check for a start
                    int cstart = line.indexOf(COMMENT_MULTILINE_START);
                    if (cstart >= 0) {
                        // This could be a MLC on one line ...
                        int cend = line.indexOf(COMMENT_MULTILINE_END, cstart + COMMENT_MULTILINE_START.length());
                        if (cend >= 0) {
                            // A comment that starts and ends on one line
                            // BUG: you can have more than 1 multi-line comment on a line
                            line = line.substring(0, cstart) + SPACE + line.substring(cend + COMMENT_MULTILINE_END.length());
                        } else {
                            // A real multi-line comment
                            inMultiLine = true;
                            line = line.substring(0, cstart) + SPACE;
                        }
                    } else {
                        // We are not in a multi line comment and we havn't
                        // started one so we are going to ignore closing
                        // comments even if they exist.
                    }
                } else {
                    // We are in a multi-line comment, check for the end
                    int cend = line.indexOf(COMMENT_MULTILINE_END);
                    if (cend >= 0) {
                        // End of comment
                        line = line.substring(cend + COMMENT_MULTILINE_END.length());
                        inMultiLine = false;
                    } else {
                        // The comment continues
                        line = SPACE;
                    }
                }

                output.append(line);
                output.append('\n');
            }

            return output.toString();
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
885663
@Override
  public Fact addComment(String comment, Context ctx)
          throws KbTypeException, CreateException {
    return wrapped().addComment(comment, ctx);
  }
636835
public void addComment(Comment comment) {
        assertNotNull(comment);
        if (comments == null) {
            comments = new TreeSet<Comment>(new AstNode.PositionComparator());
        }
        comments.add(comment);
        comment.setParent(this);
    }
1331935
private static void printComments(String comment) {
    int index = 0;
    int nextIndex = 154;
    while(index < comment.length()) {
      nextIndex = nextIndex <= comment.length() ? nextIndex : comment.length();
      String commentSegment = comment.substring(index, nextIndex);
      int lastSpace = commentSegment.lastIndexOf(' ');
      int lastNewLine = commentSegment.indexOf('\n');
      char lastChar = ' ';
      if(nextIndex < comment.length() ) {
        lastChar = comment.charAt(nextIndex);
      }
      if(lastNewLine > 0) {
        nextIndex = index + lastNewLine;
        commentSegment = comment.substring(index, nextIndex);
      } else
      if(Character.isWhitespace(lastChar)) {
        
      } else
      if(lastSpace > 0) {
        nextIndex = index + lastSpace;
        commentSegment = comment.substring(index, nextIndex);
      }
      System.out.println("  " + commentSegment);
      index = nextIndex;
      if(lastNewLine > 0 || lastSpace > 0) {
        index++;
      }
      nextIndex = index + 154;
    }
  }
1349743
public String markdownToHtml(char[] markdownSource, LinkRenderer linkRenderer) {
	    return markdownToHtml(markdownSource, linkRenderer, Collections.<String, VerbatimSerializer>emptyMap());
    }
1043923
function comment() {
        whitespace();

        if (css[0] !== '/' || css[1] !== '*') {
            return;
        }

        let i = 2;

        while (css[i] && (css[i] !== '*' || css[i + 1] !== '/')) {
            i++;
        }

        if (!css[i]) {
            return error('end of comment is missing');
        }

        const str = css.slice(2, i);

        css = css.slice(i + 2);

        return {
            type   : 'comment',
            comment: str
        };
    }
189645
protected static Comment transformComment(CSNodeWrapper node) {
        final Comment comment;
        if (node.getNodeType() == CommonConstants.CS_NODE_COMMENT) {
            comment = new Comment(node.getTitle());
        } else {
            throw new IllegalArgumentException("The passed node is not a Comment");
        }

        comment.setUniqueId(node.getId() == null ? null : node.getId().toString());

        return comment;
    }
255917
function createCommentDiv(comment) {
    if (!comment.displayed && !opts.moderator) {
      return $('<div class="moderate">Thank you!  Your comment will show up '
               + 'once it is has been approved by a moderator.</div>');
    }
    // Prettify the comment rating.
    comment.pretty_rating = comment.rating + ' point' +
      (comment.rating == 1 ? '' : 's');
    // Make a class (for displaying not yet moderated comments differently)
    comment.css_class = comment.displayed ? '' : ' moderate';
    // Create a div for this comment.
    var context = $.extend({}, opts, comment);
    var div = $(renderTemplate(commentTemplate, context));

    // If the user has voted on this comment, highlight the correct arrow.
    if (comment.vote) {
      var direction = (comment.vote == 1) ? 'u' : 'd';
      div.find('#' + direction + 'v' + comment.id).hide();
      div.find('#' + direction + 'u' + comment.id).show();
    }

    if (opts.moderator || comment.text != '[deleted]') {
      div.find('a.reply').show();
      if (comment.proposal_diff)
        div.find('#sp' + comment.id).show();
      if (opts.moderator && !comment.displayed)
        div.find('#cm' + comment.id).show();
      if (opts.moderator || (opts.username == comment.username))
        div.find('#dc' + comment.id).show();
    }
    return div;
  }
754068
public final void mSTATEMENT_COMMENT() throws RecognitionException {
        try {
            int _type = STATEMENT_COMMENT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // BELScript.g:257:18: ( '//' ( ( '\\\\\\n' ) | ( '\\\\\\r\\n' ) | ~ ( '\\n' | '\\r' ) )* )
            // BELScript.g:258:5: '//' ( ( '\\\\\\n' ) | ( '\\\\\\r\\n' ) | ~ ( '\\n' | '\\r' ) )*
            {
            match("//"); 

            // BELScript.g:258:10: ( ( '\\\\\\n' ) | ( '\\\\\\r\\n' ) | ~ ( '\\n' | '\\r' ) )*
            loop2:
            do {
                int alt2=4;
                int LA2_0 = input.LA(1);

                if ( (LA2_0=='\\') ) {
                    switch ( input.LA(2) ) {
                    case '\n':
                        {
                        alt2=1;
                        }
                        break;
                    case '\r':
                        {
                        alt2=2;
                        }
                        break;

                    default:
                        alt2=3;
                        break;
                    }

                }
                else if ( ((LA2_0>='\u0000' && LA2_0<='\t')||(LA2_0>='\u000B' && LA2_0<='\f')||(LA2_0>='\u000E' && LA2_0<='[')||(LA2_0>=']' && LA2_0<='\uFFFF')) ) {
                    alt2=3;
                }


                switch (alt2) {
            	case 1 :
            	    // BELScript.g:258:11: ( '\\\\\\n' )
            	    {
            	    // BELScript.g:258:11: ( '\\\\\\n' )
            	    // BELScript.g:258:12: '\\\\\\n'
            	    {
            	    match("\\\n"); 


            	    }


            	    }
            	    break;
            	case 2 :
            	    // BELScript.g:258:22: ( '\\\\\\r\\n' )
            	    {
            	    // BELScript.g:258:22: ( '\\\\\\r\\n' )
            	    // BELScript.g:258:23: '\\\\\\r\\n'
            	    {
            	    match("\\\r\n"); 


            	    }


            	    }
            	    break;
            	case 3 :
            	    // BELScript.g:258:35: ~ ( '\\n' | '\\r' )
            	    {
            	    if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) {
            	        input.consume();

            	    }
            	    else {
            	        MismatchedSetException mse = new MismatchedSetException(null,input);
            	        recover(mse);
            	        throw mse;}


            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
76519
public StringBuffer render(StringBuffer buffer, Object... arguments)
    {

        return format(arguments, buffer, null);

    }
698860
public void addComment(String tag, String comment) {
        String nt = normaliseTag(tag);
        if(! comments.containsKey(nt)) {
            comments.put(nt, new ArrayList<String>());
        }
        comments.get(nt).add(comment);
    }
263073
static Comment asEngineComment(final IComment comment) {
        if (comment instanceof Comment) {
            return (Comment) comment;
        }
        return new Comment(comment.getContent(), comment.getTemplateName(), comment.getLine(), comment.getCol());
    }
713738
public static String getTextFromComment(Comment comment) {
    switch (comment.getStyle()) {
      case BLOCK:
        return comment.getText().replaceAll("^\\s*/\\*\\s*(.*?)\\s*\\*/\\s*", "$1");
      case LINE:
        return comment.getText().replaceAll("^\\s*//\\s*", "");
      default:
        return comment.getText();
    }
  }