Revert changes made in refactor

We need the original superscript markdown for when we edit posts!
This commit is contained in:
scria1000 2021-11-14 21:48:11 +03:00
parent a52342b336
commit 550706d2d7
11 changed files with 16 additions and 13 deletions

View File

@ -177,7 +177,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override
@ -231,7 +231,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -148,7 +148,7 @@ public class FullMarkdownActivity extends BaseActivity {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -173,7 +173,7 @@ public class WikiActivity extends BaseActivity {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -133,7 +133,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -178,7 +178,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -117,7 +117,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -243,7 +243,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -83,7 +83,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -58,7 +58,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -122,7 +122,7 @@ public class SidebarFragment extends Fragment {
@NonNull
@Override
public String processMarkdown(@NonNull String markdown) {
return super.processMarkdown(markdown);
return super.processMarkdown(Utils.fixSuperScript(markdown));
}
@Override

View File

@ -73,10 +73,13 @@ public class Utils {
.replaceAll("(^|^ *|\\n *)#####(?!($|\\s|#))", "$0 ")
.replaceAll("(^|^ *|\\n *)######(?!($|\\s|#))", "$0 "));
return fixSuperScript(regexed);
//return fixSuperScript(regexed);
// We don't want to fix super scripts here because we need the original markdown later for editing posts
return regexed.toString();
}
private static String fixSuperScript(StringBuilder regexed) {
public static String fixSuperScript(String regexedMarkdown) {
StringBuilder regexed = new StringBuilder(regexedMarkdown);
boolean hasBracket = false;
int nCarets = 0;
for (int i = 0; i < regexed.length(); i++) {