[HTML] Add support for block quotes

Closes #208
pull/236/head
Alexey Golub 5 years ago
parent cd042e5368
commit d88cd9b228

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using DiscordChatExporter.Core.Markdown.Internal;
@ -57,6 +57,18 @@ namespace DiscordChatExporter.Core.Markdown
new Regex("\\|\\|(.+?)\\|\\|", DefaultRegexOptions | RegexOptions.Singleline),
(p, m) => new FormattedNode(TextFormatting.Spoiler, Parse(p.Shrink(m.Groups[1]))));
// Capture any character until the end of the line
// Opening 'greater than' character must be followed by whitespace
private static readonly IMatcher<Node> SingleLineQuoteNodeMatcher = new RegexMatcher<Node>(
new Regex("^>\\s(.+)\r?\n?", DefaultRegexOptions),
(p, m) => new FormattedNode(TextFormatting.Quote, Parse(p.Shrink(m.Groups[1]))));
// Capture any character until the end of the input
// Opening 'greater than' characters must be followed by whitespace
private static readonly IMatcher<Node> MultiLineQuoteNodeMatcher = new RegexMatcher<Node>(
new Regex("^>>>\\s(.+)", DefaultRegexOptions | RegexOptions.Singleline),
(p, m) => new FormattedNode(TextFormatting.Quote, Parse(p.Shrink(m.Groups[1]))));
/* Code blocks */
// Capture any character except backtick until a backtick
@ -176,6 +188,8 @@ namespace DiscordChatExporter.Core.Markdown
ItalicAltFormattedNodeMatcher,
StrikethroughFormattedNodeMatcher,
SpoilerFormattedNodeMatcher,
MultiLineQuoteNodeMatcher,
SingleLineQuoteNodeMatcher,
// Code blocks
MultiLineCodeBlockNodeMatcher,

@ -6,6 +6,7 @@
Italic,
Underline,
Strikethrough,
Spoiler
Spoiler,
Quote
}
}

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@ -81,6 +81,10 @@ namespace DiscordChatExporter.Core.Rendering
// Spoiler
if (formattedNode.Formatting == TextFormatting.Spoiler)
return $"<span class=\"spoiler\">{innerHtml}</span>";
// Quote
if (formattedNode.Formatting == TextFormatting.Quote)
return $"<div class=\"quote\">{innerHtml}</div>";
}
// Inline code block node

@ -1,4 +1,4 @@
/* === GENERAL === */
/* === GENERAL === */
body {
background-color: #36393e;
@ -13,6 +13,10 @@ a {
background-color: rgba(255, 255, 255, 0.1);
}
.quote {
border-color: #4f545c;
}
.pre {
background-color: #2f3136 !important;
}

@ -1,4 +1,4 @@
/* === GENERAL === */
/* === GENERAL === */
body {
background-color: #ffffff;
@ -14,6 +14,10 @@ a {
background-color: rgba(0, 0, 0, 0.1);
}
.quote {
border-color: #c7ccd1;
}
.pre {
background-color: #f9f9f9 !important;
}

@ -57,6 +57,13 @@ img {
border-radius: 3px;
}
.quote {
border-left: 4px solid;
border-radius: 3px;
margin: 8px 0;
padding-left: 10px;
}
.pre {
font-family: "Consolas", "Courier New", Courier, monospace;
}

Loading…
Cancel
Save