diff --git a/CHANGELOG.md b/CHANGELOG.md index df676f8f..d8cc8ed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ # 4.2.2-SNAPSHOT * Fixed `AsyncDrawable` display when it has placeholder with empty bounds ([#189]) +* Fixed `syntax-highlight` where code input is empty string ([#192]) [#189]: https://github.com/noties/Markwon/issues/189 +[#192]: https://github.com/noties/Markwon/issues/192 # 4.2.1 * Fix SpannableBuilder `subSequence` method diff --git a/markwon-syntax-highlight/src/main/java/io/noties/markwon/syntax/Prism4jSyntaxHighlight.java b/markwon-syntax-highlight/src/main/java/io/noties/markwon/syntax/Prism4jSyntaxHighlight.java index cc78c401..c6ebbd39 100644 --- a/markwon-syntax-highlight/src/main/java/io/noties/markwon/syntax/Prism4jSyntaxHighlight.java +++ b/markwon-syntax-highlight/src/main/java/io/noties/markwon/syntax/Prism4jSyntaxHighlight.java @@ -41,6 +41,13 @@ public class Prism4jSyntaxHighlight implements SyntaxHighlight { @NonNull @Override public CharSequence highlight(@Nullable String info, @NonNull String code) { + + // @since 4.2.2-SNAPSHOT + // although not null, but still is empty + if (code.isEmpty()) { + return code; + } + // if info is null, do not highlight -> LICENCE footer very commonly wrapped inside code // block without syntax name specified (so, do not highlight) return info == null