diff --git a/lib/widgets/chat_page/html/code_block.dart b/lib/widgets/chat_page/html/code_block.dart index fe5b492..276d4f9 100644 --- a/lib/widgets/chat_page/html/code_block.dart +++ b/lib/widgets/chat_page/html/code_block.dart @@ -41,6 +41,7 @@ class CodeBlock extends StatelessWidget { padding: EdgeInsets.all(8), child: SelectableText( code, + maxLines: 99, style: TextStyle(fontFamily: "monospace"), ), ), diff --git a/lib/widgets/chat_page/html/html.dart b/lib/widgets/chat_page/html/html.dart index 18edf4a..32e3de7 100644 --- a/lib/widgets/chat_page/html/html.dart +++ b/lib/widgets/chat_page/html/html.dart @@ -30,10 +30,14 @@ class Html extends ConsumerWidget { return switch (element.localName) { "code" => element.parent?.localName == "pre" - ? CodeBlock( - element.text, - lang: element.className.replaceAll("language-", ""), - ) + ? element.outerHtml.contains("
") + ? Html( + """
${element.outerHtml.replaceAll("
", "\n")}
""", + ) + : CodeBlock( + element.text, + lang: element.className.replaceAll("language-", ""), + ) : null, "blockquote" => Quoted(Html(element.innerHtml)), diff --git a/lib/widgets/chat_page/room_chat.dart b/lib/widgets/chat_page/room_chat.dart index 6adc013..c344ae6 100644 --- a/lib/widgets/chat_page/room_chat.dart +++ b/lib/widgets/chat_page/room_chat.dart @@ -409,7 +409,10 @@ class RoomChat extends HookConsumerWidget { return "$url"; }, ) - .replaceAll("\n", "
"), + .replaceAll( + "\n", + "
", + ), ), if (message.editedAt != null) Text(