Skip to content

Commit

Permalink
feat: add support for annotation text in Stringifier
Browse files Browse the repository at this point in the history
Implement handling for `R.AnnotationRef` and `annotation text` cases in Stringifier methods. This change ensures consistent processing of annotation-related content, preventing potential null pointer exceptions.
  • Loading branch information
caring-coder committed Dec 5, 2024
1 parent 6f052f0 commit d36bd61
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public String stringify(Object o) {
if (o instanceof CTShadow) return "";
if (o instanceof SdtRun run) return stringify(run.getSdtContent());
if (o instanceof SdtContent content) return stringify(content);
if (o instanceof R.AnnotationRef) return "";
if (o == null) throw new RuntimeException("Unsupported content: NULL");
throw new RuntimeException("Unsupported content: " + o.getClass());
}
Expand Down Expand Up @@ -515,6 +516,7 @@ private Function<? super String, String> decorateWithStyle(String value) {
case "heading 5" -> "====== %s\n"::formatted;
case "heading 6" -> "======= %s\n"::formatted;
case "caption" -> ".%s"::formatted;
case "annotation text" -> string -> string;
default -> "[%s] %%s".formatted(value)::formatted;
};
}
Expand Down

0 comments on commit d36bd61

Please sign in to comment.