Skip to content

Commit

Permalink
Handle strong in JavaDocParser
Browse files Browse the repository at this point in the history
And handle emphasis with italic, not bold as in HTML.
  • Loading branch information
gsmet committed Mar 1, 2023
1 parent ce62d50 commit af98a8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ final class JavaDocParser {
private static final String NEW_LINE = "\n";
private static final String LINK_NODE = "a";
private static final String BOLD_NODE = "b";
private static final String STRONG_NODE = "strong";
private static final String BIG_NODE = "big";
private static final String CODE_NODE = "code";
private static final String DEL_NODE = "del";
private static final String ITALICS_NODE = "i";
private static final String EMPHASIS_NODE = "em";
private static final String TEXT_NODE = "#text";
private static final String UNDERLINE_NODE = "u";
private static final String NEW_LINE_NODE = "br";
private static final String PARAGRAPH_NODE = "p";
private static final String SMALL_NODE = "small";
private static final String EMPHASIS_NODE = "em";
private static final String LIST_ITEM_NODE = "li";
private static final String HREF_ATTRIBUTE = "href";
private static final String STRIKE_NODE = "strike";
Expand Down Expand Up @@ -220,11 +221,12 @@ private void appendHtml(StringBuilder sb, Node node) {
sb.append(BACKTICK);
break;
case BOLD_NODE:
case EMPHASIS_NODE:
case STRONG_NODE:
sb.append(STAR);
appendHtml(sb, childNode);
sb.append(STAR);
break;
case EMPHASIS_NODE:
case ITALICS_NODE:
sb.append(UNDERSCORE);
appendHtml(sb, childNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ public void parseJavaDocWithStyles() {
String parsed = parser.parseConfigDescription(javaDoc);
assertEquals(expectedOutput, parsed);

javaDoc = "hello <strong>world</strong>";
expectedOutput = "hello *world*";
parsed = parser.parseConfigDescription(javaDoc);
assertEquals(expectedOutput, parsed);

// Emphasized
javaDoc = "<em>hello world</em>";
expectedOutput = "*hello world*";
expectedOutput = "_hello world_";
parsed = parser.parseConfigDescription(javaDoc);
assertEquals(expectedOutput, parsed);

Expand Down

0 comments on commit af98a8b

Please sign in to comment.