Skip to content

Commit

Permalink
Enabled quotes references
Browse files Browse the repository at this point in the history
  • Loading branch information
Str4tocaster committed Jul 9, 2019
1 parent 3b80478 commit 2e38f01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static Pair<String, String> modifyBodyWithReferences(Message message, Str

// modify chars with references except markup and mention
for (ReferenceElement reference : references) {
if (!(reference instanceof Markup) && !(reference instanceof Mention))
if (!(reference instanceof Markup) && !(reference instanceof Mention) && !(reference instanceof Quote))
chars = modifyBodyWithReferences(chars, reference);
}

Expand All @@ -105,7 +105,7 @@ public static Pair<String, String> modifyBodyWithReferences(Message message, Str

// modify chars with markup and mention references
for (ReferenceElement reference : references) {
if (reference instanceof Markup || reference instanceof Mention)
if (reference instanceof Markup || reference instanceof Mention || reference instanceof Quote)
chars = modifyBodyWithReferences(chars, reference);
}
markupBody = charsToString(chars);
Expand Down Expand Up @@ -163,7 +163,7 @@ private static String[] modifyBodyWithReferences(String[] chars, ReferenceElemen
chars = markup(begin, end, chars, (Markup) reference);
break;
case quote:
//chars = removeInLine(begin, end, chars, (Quote) reference);
chars = quote(begin, end, chars, (Quote) reference);
break;
case mention:
chars = mention(begin, end, chars, (Mention) reference);
Expand All @@ -179,12 +179,13 @@ private static String[] remove(int begin, int end, String[] source) {
return source;
}

private static String[] removeInLine(int begin, int end, String[] source, Quote reference) {
private static String[] quote(int begin, int end, String[] source, Quote reference) {
int del = reference.getMarker().length();
int removed = 0;
for (int i = begin; i <= end; i++) {
if (removed < del) {
source[i] = String.valueOf(Character.MIN_VALUE);
if (removed == 0) source[i] = "<font color='#9e9e9e'>\u2503</font> ";
else source[i] = String.valueOf(Character.MIN_VALUE);
removed++;
}
if (source[i].equals("\n")) removed = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ public void modifyBodyWithReferences3() {
"<u>Использование</u> <strike>нескольких</strike> стилей.", result.second);
}

// @Test
// public void modifyBodyWithReferences4() {
// String expected = "This is a quote\n" +
// "of two lines\n" +
// "Hello world!";
// Pair<String, String> result = ReferencesManager.modifyBodyWithReferences(message4, body4);
// assertEquals(expected, result.first);
// assertNull(result.second);
// }
@Test
public void modifyBodyWithReferences4() {
String expected = "<font color='#9e9e9e'>\u2503</font> This is a quote\n" +
"<font color='#9e9e9e'>\u2503</font> of two lines\n" +
"Hello world!";
Pair<String, String> result = ReferencesManager.modifyBodyWithReferences(message4, body4);
assertEquals(body4, result.first);
assertEquals(expected, result.second);
}

@Test
public void modifyBodyWithReferences5() {
Expand Down

0 comments on commit 2e38f01

Please sign in to comment.