From 1e853f11b08af4c52c1c2cad2c366fca13bc11d3 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Sun, 1 Oct 2017 01:49:26 +0300 Subject: [PATCH] Fix styling for pre --- .../Resources/ExportService/DarkTheme.css | 4 ++++ .../Resources/ExportService/LightTheme.css | 2 ++ DiscordChatExporter/Services/ExportService.cs | 16 ++++++++-------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/DiscordChatExporter/Resources/ExportService/DarkTheme.css b/DiscordChatExporter/Resources/ExportService/DarkTheme.css index e5e2000..9ca9d5b 100644 --- a/DiscordChatExporter/Resources/ExportService/DarkTheme.css +++ b/DiscordChatExporter/Resources/ExportService/DarkTheme.css @@ -14,8 +14,11 @@ a:hover { text-decoration: underline; } div.pre { background-color: #2F3136; + color: rgb(131, 148, 150); font-family: Consolas, Courier New, Courier, Monospace; + margin-top: 4px; padding: 8px; + white-space: pre; } span.pre { @@ -23,6 +26,7 @@ span.pre { font-family: Consolas, Courier New, Courier, Monospace; padding-left: 2px; padding-right: 2px; + white-space: pre; } div#info { diff --git a/DiscordChatExporter/Resources/ExportService/LightTheme.css b/DiscordChatExporter/Resources/ExportService/LightTheme.css index 922789e..83b139a 100644 --- a/DiscordChatExporter/Resources/ExportService/LightTheme.css +++ b/DiscordChatExporter/Resources/ExportService/LightTheme.css @@ -14,7 +14,9 @@ a:hover { text-decoration: underline; } div.pre { background-color: #F9F9F9; + color: rgb(101, 123, 131); font-family: Consolas, Courier New, Courier, Monospace; + margin-top: 4px; padding: 8px; } diff --git a/DiscordChatExporter/Services/ExportService.cs b/DiscordChatExporter/Services/ExportService.cs index e08ac60..2d3e123 100644 --- a/DiscordChatExporter/Services/ExportService.cs +++ b/DiscordChatExporter/Services/ExportService.cs @@ -218,18 +218,18 @@ namespace DiscordChatExporter.Services // Encode HTML content = HtmlEncode(content); + // Preformatted div + content = Regex.Replace(content, "```+(?:[^`]*?\\n)?([^`]+)\\n?```+", + m => "
" + m.Groups[1].Value + "
"); + + // Preformatted span + content = Regex.Replace(content, "`([^`]+)`", + m => "" + m.Groups[1].Value + ""); + // Links from URLs content = Regex.Replace(content, "((https?|ftp)://[^\\s/$.?#].[^\\s]*)", "$1"); - // Preformatted multiline - content = Regex.Replace(content, "```([^`]*?)```", - m => "
" + m.Groups[1].Value.Trim('\n') + "
"); - - // Preformatted inline - content = Regex.Replace(content, "`([^`]*?)`", - m => "" + m.Groups[1].Value + ""); - // Bold content = Regex.Replace(content, "\\*\\*([^\\*]*?)\\*\\*", "$1");