Fix tests (for real this time)

This commit is contained in:
Nassim Jahnke 2023-02-15 16:57:16 +01:00
parent ed3dbf72ae
commit d97a7ff698
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 20 additions and 16 deletions

View File

@ -18,24 +18,24 @@ public class BBCodeConverter {
private String currentContent;
static {
// Remove tags
REPLACERS.put("color", (tag, tagArg, content) -> content);
REPLACERS.put("left", (tag, tagArg, content) -> content);
REPLACERS.put("right", (tag, tagArg, content) -> content);
REPLACERS.put("u", (tag, tagArg, content) -> content);
REPLACERS.put("quote", (tag, tagArg, content) -> content);
REPLACERS.put("font", (tag, tagArg, content) -> content);
REPLACERS.put("user", (tag, tagArg, content) -> content);
REPLACERS.put("list", (tag, tagArg, content) -> content);
final TagReplacer removeTag = (tag, tagArg, content) -> content;
REPLACERS.put("color", removeTag);
REPLACERS.put("left", removeTag);
REPLACERS.put("right", removeTag);
REPLACERS.put("u", removeTag);
REPLACERS.put("quote", removeTag);
REPLACERS.put("font", removeTag);
REPLACERS.put("user", removeTag);
REPLACERS.put("list", removeTag);
REPLACERS.put("attach", (tag, tagArg, content) -> "");
REPLACERS.put("b", encaseIfNotBlank("**", "**"));
REPLACERS.put("i", encaseIfNotBlank("*", "*"));
REPLACERS.put("s", encaseIfNotBlank("~~", "~~"));
REPLACERS.put("center", encaseIfNotBlank("<center>", "</center>"));
REPLACERS.put("spoiler", (tag, tagArg, content) -> "<details>\n<summary>%s</summary>\n\n%s\n</details>\n".formatted(removeQuotes(tagArg), content));
REPLACERS.put("b", (tag, tagArg, content) -> "**" + content + "**");
REPLACERS.put("i", (tag, tagArg, content) -> "*" + content + "*");
REPLACERS.put("s", (tag, tagArg, content) -> "~~" + content + "~~");
REPLACERS.put("img", (tag, tagArg, content) -> "![" + content + "](" + content + ")");
REPLACERS.put("media", (tag, tagArg, content) -> "youtube".equals(tagArg) ? "@[YouTube](https://youtu.be/" + content + ")" : null);
REPLACERS.put("center", (tag, tagArg, content) -> "<center>" + content + "</center>");
REPLACERS.put("size", (tag, tagArg, content) -> {
if (content.isBlank()) {
return content;
@ -125,6 +125,10 @@ public class BBCodeConverter {
SIMPLE_SINGLETON_REPLACERS.put("*", "* ");
}
private static TagReplacer encaseIfNotBlank(final String prefix, final String suffix) {
return (tag, tagArg, content) -> content.isBlank() ? content : prefix + content + suffix;
}
/**
* Converts the given BBcode input to Markdown.
*

View File

@ -25,13 +25,13 @@ Its features include:
IMPORTANT: If using the plugin on a Spigot server, the plugin **[ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/)** is required to use Maintenance to its full extend.
<center></center>
### Did you find a bug? Use the [**issue tracker**](https://github.com/kennytv/maintenance/issues)
<center>### Did you find a bug? Use the [**issue tracker**](https://github.com/kennytv/maintenance/issues)
Other questions or problems? Click the wonderful icon below ✨
[](https://discord.gg/vgcuzhq)
</center>
*Arguments in < > are necessary, those in [ ] aren't (can be omitted).*