String (boolean isInTable, @NotNull List<String> parts, @Nullable List<String> tableFormats) { String openingTagStart = isInTable ? "<td style=\"" + getBorder() + "\" " : "<th style=\"" + getBorder() + "\" "; String closingTag = isInTable ? "</td>" : "</th>"; StringBuilder resultBuilder = new StringBuilder("<tr style=\"" + getBorder() + "\">" + openingTagStart); resultBuilder.append("align=\"").append(getAlign(0, tableFormats)).append("\">"); for (int i = 0; i < parts.size(); i++) { if (i > 0) { resultBuilder.append(closingTag).append(openingTagStart).append("align=\"").append(getAlign(i, tableFormats)).append("\">"); } resultBuilder.append(convert(parts.get(i).trim())); } resultBuilder.append(closingTag).append("</tr>"); return resultBuilder.toString(); }