TextLeaf implements LogEntryComponent { @Override public String toHtml() { String result = mText.replaceAll("\\r\\n?|\\n", "<br />"); if (mOptions.getTextColor() != null) { result = "<font color='" + mOptions.getTextColor() + "'>" + result + "</font>"; } else { result = "<font color='#FFF'>" + result + "</font>"; } if (mOptions.isBold()) { result = "<b>" + result + "</b>"; } if (mOptions.isItalic()) { result = "<i>" + result + "</i>"; } return result; } TextLeaf();   TextLeaf(String text);   TextLeaf(FormattingOptions options);  TextLeaf(String text, FormattingOptions options); FormattingOptions getOptions(); void setOptions(FormattingOptions options); String getText(); void setText(String text); @Override String toHtml(); @Override String toString();  }
@Test public void toHtml() throws Exception { TextLeaf text = new TextLeaf("T", FormattingOptions.fromAnsiCodes(new String[]{"34", "1"})); assertEquals("<b><font color='#96CBFE'>T</font></b>", text.toHtml()); }