Skip to content

Commit

Permalink
Prevent invalid markdown when JavaDoc ends in source block
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Feb 8, 2025
1 parent 350db92 commit bb90157
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ private String recipeDescriptor(JCTree.JCClassDecl classDecl, String defaultDisp
displayName = firstLine;
description = new StringBuilder(lines[1].trim().replace("\n", "\\n"));
if (!description.toString().endsWith(".")) {
if (description.toString().endsWith("```")) {
description.append("\\n");
}
description.append('.');
}
}
Expand Down Expand Up @@ -538,7 +541,7 @@ private String recipeDescriptor(JCTree.JCClassDecl classDecl, String defaultDisp
break;
} else if ("tech.picnic.errorprone.refaster.annotation.OnlineDocumentation".equals(annotationFqn)) {
if (annotation.getArguments().isEmpty()) {
description.append(" [Source](https://error-prone.picnic.tech/refasterrules/").append(classDecl.name.toString()).append(").");
description.append("\\n[Source](https://error-prone.picnic.tech/refasterrules/").append(classDecl.name.toString()).append(").");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/refaster/PicnicRulesRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getDisplayName() {

@Override
public String getDescription() {
return "Picnic rules for refaster, showing how JavaDoc is converted to Markdown [Source](https://error-prone.picnic.tech/refasterrules/PicnicRules).";
return "Picnic rules for refaster, showing how JavaDoc is converted to Markdown\n[Source](https://error-prone.picnic.tech/refasterrules/PicnicRules).";
}

@Override
Expand Down

0 comments on commit bb90157

Please sign in to comment.