mirror of
https://github.com/System-End/Discord-MC-Chat.git
synced 2026-04-19 22:05:11 +00:00
fix: enhance code block formatting in DiscordMessageParser
This commit is contained in:
parent
94fd14f738
commit
1e798f4156
1 changed files with 9 additions and 1 deletions
|
|
@ -961,7 +961,15 @@ List<TextSegment> codeSegments;
|
|||
if ("ansi".equalsIgnoreCase(language) && ConfigManager.getBoolean("message_parsing.discord_to_minecraft.ansi_code_blocks")) {
|
||||
codeSegments = parseAnsiContent(content);
|
||||
} else {
|
||||
codeSegments = List.of(new TextSegment("[" + content + "]"));
|
||||
StringBuilder sb = new StringBuilder("<code lang=[").append(language).append("]>");
|
||||
|
||||
// For each line of content string
|
||||
for (String line : content.split("\n", 0)) {
|
||||
sb.append("\n ").append(line);
|
||||
}
|
||||
sb.append("\n</code>");
|
||||
|
||||
codeSegments = List.of(new TextSegment(sb.toString()));
|
||||
}
|
||||
|
||||
spans.add(new MarkdownSpan(matcher.start(), matcher.end(), content, MarkdownType.CODE_BLOCK, codeSegments));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue