Add underscore italics to markdown formatter

Fixes #15
This commit is contained in:
Alexey Golub 2017-10-25 22:04:47 +03:00
parent 6968f987ce
commit 42d4d64695

View file

@ -220,28 +220,31 @@ namespace DiscordChatExporter.Services
// Encode HTML
content = HtmlEncode(content);
// Preformatted div
// Pre multiline (```text```)
content = Regex.Replace(content, "```+(?:[^`]*?\\n)?([^`]+)\\n?```+",
m => "<div class=\"pre\">" + m.Groups[1].Value + "</div>");
// Preformatted span
// Pre inline (`text`)
content = Regex.Replace(content, "`([^`]+)`",
m => "<span class=\"pre\">" + m.Groups[1].Value + "</span>");
// Links from URLs
// URL links
content = Regex.Replace(content, "((https?|ftp)://[^\\s/$.?#].[^\\s]*)",
"<a href=\"$1\">$1</a>");
// Bold
// Bold (**text**)
content = Regex.Replace(content, "\\*\\*([^\\*]*?)\\*\\*", "<b>$1</b>");
// Italic
// Italic (*text*)
content = Regex.Replace(content, "\\*([^\\*]*?)\\*", "<i>$1</i>");
// Underline
// Underline (__text__)
content = Regex.Replace(content, "__([^_]*?)__", "<u>$1</u>");
// Strike through
// Italic (_text_)
content = Regex.Replace(content, "_([^_]*?)_", "<i>$1</i>");
// Strike through (~~text~~)
content = Regex.Replace(content, "~~([^~]*?)~~", "<s>$1</s>");
// New lines