diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-12-17 12:48:09 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-12-17 18:14:29 +0300 |
commit | c6aff34f2e84c6c49f4b4d5dd2cb24950342deef (patch) | |
tree | 3594ce0704c6973bd3b2be4fea4035851d44055c | |
parent | 82c175c3777840a132b3f83c8b62a1f7f436d60d (diff) |
Add some JavaDoc
Signed-off-by: Stefan Niedermann <info@niedermann.it>
-rw-r--r-- | markdown/src/androidTest/java/it/niedermann/android/markdown/MarkwonMarkdownUtilTest.java | 4 | ||||
-rw-r--r-- | markdown/src/main/java/it/niedermann/android/markdown/markwon/MarkwonMarkdownUtil.java | 17 |
2 files changed, 16 insertions, 5 deletions
diff --git a/markdown/src/androidTest/java/it/niedermann/android/markdown/MarkwonMarkdownUtilTest.java b/markdown/src/androidTest/java/it/niedermann/android/markdown/MarkwonMarkdownUtilTest.java index ead2985b4..f09c14134 100644 --- a/markdown/src/androidTest/java/it/niedermann/android/markdown/MarkwonMarkdownUtilTest.java +++ b/markdown/src/androidTest/java/it/niedermann/android/markdown/MarkwonMarkdownUtilTest.java @@ -185,12 +185,12 @@ public class MarkwonMarkdownUtilTest extends TestCase { // Special use-case: toggle from italic to bold and back - // Toggle italic on bold text + // TODO Toggle italic on bold text // builder = new StringBuilder("Lorem **ipsum** dolor sit amet."); // assertEquals(17, MarkwonMarkdownUtil.togglePunctuation(builder, 8, 13, "*")); // assertEquals("Lorem ***ipsum*** dolor sit amet.", builder.toString()); - // Toggle bold on italic text + // TODO Toggle bold on italic text // builder = new StringBuilder("Lorem *ipsum* dolor sit amet."); // assertEquals(17, MarkwonMarkdownUtil.togglePunctuation(builder, 7, 12, "**")); // assertEquals("Lorem ***ipsum*** dolor sit amet.", builder.toString()); diff --git a/markdown/src/main/java/it/niedermann/android/markdown/markwon/MarkwonMarkdownUtil.java b/markdown/src/main/java/it/niedermann/android/markdown/markwon/MarkwonMarkdownUtil.java index 559221ad6..d4e388187 100644 --- a/markdown/src/main/java/it/niedermann/android/markdown/markwon/MarkwonMarkdownUtil.java +++ b/markdown/src/main/java/it/niedermann/android/markdown/markwon/MarkwonMarkdownUtil.java @@ -169,6 +169,10 @@ public class MarkwonMarkdownUtil { : selectionEnd + 3; } + /** + * @return whether or not the selection of {@param text} from {@param start} to {@param end} is + * surrounded or not by the given {@param punctuation}. + */ private static boolean selectionIsSurroundedByPunctuation(@NonNull CharSequence text, int start, int end, @NonNull String punctuation) { if (text.length() < end + punctuation.length()) { return false; @@ -180,8 +184,15 @@ public class MarkwonMarkdownUtil { && punctuation.contentEquals(text.subSequence(end, end + punctuation.length())); } - private static void removeSurroundingPunctuation(@NonNull StringBuilder ssb, int start, int end, @NonNull String punctuation) { - ssb.delete(end, end + punctuation.length()); - ssb.delete(start - punctuation.length(), start); + /** + * Mutates the given {@param builder} and removes the text range from {@param start} to + * {@param end} and its surrounding {@param punctuation}. + * Doesn't make any assumptions about the text lengths and will throw a + * {@link StringIndexOutOfBoundsException} if {@param start}, {@param end} or the + * {@param punctuation} is out of range of the given {@param builder}. + */ + private static void removeSurroundingPunctuation(@NonNull StringBuilder builder, int start, int end, @NonNull String punctuation) throws StringIndexOutOfBoundsException { + builder.delete(end, end + punctuation.length()); + builder.delete(start - punctuation.length(), start); } } |