Merge branch 'main' of https://gitlab.com/jeseibel/distant-horizons-core
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.seibel.lod.core.jar.installer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Formats Markdown to other markup languages
|
||||
*
|
||||
* @author coolGi
|
||||
*/
|
||||
public class MarkdownFormatter {
|
||||
public static abstract class GenericFormat {
|
||||
/** Converts Markdown text to a different format */
|
||||
public String convertFrom(String original) {
|
||||
System.out.println("Function \"convertFrom\" for \""+this.getClass().getSimpleName()+"\" not done yet");
|
||||
return null;
|
||||
}
|
||||
/** Converts formatted text back to Markdown */
|
||||
public String convertTo(String original) {
|
||||
System.out.println("Function \"convertTo\" for \""+this.getClass().getSimpleName()+"\" not done yet");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Split a string every n characters */
|
||||
public static List<String> splitString(String text, int n) {
|
||||
return Arrays.asList(
|
||||
text.split("(?<=\\G.{"+ n +"})")
|
||||
);
|
||||
}
|
||||
private static String replaceRegex(String text, String regex, String start, String end) {
|
||||
while (Pattern.compile(regex).matcher(text).find()) {
|
||||
text = text.replaceFirst(regex, start).replaceFirst(regex, end);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static class HTMLFormat extends GenericFormat {
|
||||
@Override
|
||||
public String convertTo(String original) {
|
||||
original = original.replaceAll("\\\\\\n", "<br>") // Removes the "\" used in markdown to create new line
|
||||
.replaceAll("\\n", "<br>"); // Fix the new line
|
||||
|
||||
original = replaceRegex(original, "\\*\\*", "<b>", "</b>"); // Makes the text bold
|
||||
original = replaceRegex(original, "~~", "<del>", "</del>"); // Striketrough
|
||||
// original = replaceRegex(original, "_", "<i>", "</i>"); // Italic
|
||||
|
||||
return original;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecraftFormat extends GenericFormat {
|
||||
@Override
|
||||
public String convertTo(String original) {
|
||||
original = original.replaceAll("<br>", "\n"); // New lines
|
||||
original = replaceRegex(original, "\\*\\*", "§l", "§r"); // Bold
|
||||
original = replaceRegex(original, "~~", "§m", "§r"); // Striketrough
|
||||
// original = replaceRegex(original, "_", "§n", "§r"); // Italic
|
||||
return original;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,9 @@ public class ModrinthGetter {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getLatestIDForVersion(String mcVer) {
|
||||
return mcVerToReleaseID.get(mcVer).get(0);
|
||||
}
|
||||
public static String getLatestNameForVersion(String mcVer) {
|
||||
return releaseNames.get(mcVerToReleaseID.get(mcVer).get(0));
|
||||
}
|
||||
|
||||
@@ -72,20 +72,8 @@ public class WebDownloader {
|
||||
}
|
||||
|
||||
public static String formatMarkdownToHtml(String md, int width) {
|
||||
String str = String.format("<html><div style=\"width:%dpx;\">%s</div></html>", width, md)
|
||||
.replaceAll("\\\\\\n", "<br>") // Removes the "\" used in markdown to create new line
|
||||
.replaceAll("\\n", "<br>"); // Fix the new line
|
||||
|
||||
boolean counter = false;
|
||||
while (str.contains("**")) {
|
||||
if (counter)
|
||||
str = str.replaceFirst("\\*\\*", "</strong>");
|
||||
else
|
||||
str = str.replaceFirst("\\*\\*", "<strong>");
|
||||
counter = !counter;
|
||||
}
|
||||
|
||||
return str;
|
||||
String str = String.format("<html><div style=\"width:%dpx;\">%s</div></html>", width, md);
|
||||
return new MarkdownFormatter.HTMLFormat().convertTo(str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
"lod.updater.title":
|
||||
"Distant Horizons auto updater",
|
||||
"lod.updater.text1":
|
||||
"§lUpdate for Distant Horizons available!",
|
||||
"§lNew update available!",
|
||||
"lod.updater.text2":
|
||||
"§fWould you like to automatically update from version %s§f to %s§f?",
|
||||
"§fDo you want to update from %s§f to %s§f?",
|
||||
"lod.updater.later":
|
||||
"Later",
|
||||
"Not now",
|
||||
"lod.updater.never":
|
||||
"Dont show again",
|
||||
"Don't show again",
|
||||
"lod.updater.update":
|
||||
"Update",
|
||||
"lod.updater.update.@tooltip":
|
||||
@@ -24,6 +24,20 @@
|
||||
"Every time an update is available, it would update\n(§6WARNING§r: It wont prompt the user on an update, tough it would keep the mod up to date)",
|
||||
|
||||
|
||||
"lod.general.back":
|
||||
"Back",
|
||||
"lod.general.next":
|
||||
"Next",
|
||||
"lod.general.done":
|
||||
"Done",
|
||||
"lod.general.cancel":
|
||||
"Cancel",
|
||||
"lod.general.yes":
|
||||
"Yes",
|
||||
"lod.general.no":
|
||||
"No",
|
||||
|
||||
|
||||
|
||||
|
||||
"lod.config.title":
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 299 B |
Reference in New Issue
Block a user