This commit is contained in:
Alexey Golub
2020-01-11 17:28:01 +02:00
parent 5c2e725739
commit 26d713a17c
26 changed files with 268 additions and 282 deletions

View File

@@ -0,0 +1,27 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public class EmojiNode : Node
{
public string? Id { get; }
public string Name { get; }
public bool IsAnimated { get; }
public bool IsCustomEmoji => !string.IsNullOrWhiteSpace(Id);
public EmojiNode(string? id, string name, bool isAnimated)
{
Id = id;
Name = name;
IsAnimated = isAnimated;
}
public EmojiNode(string name)
: this(null, name, false)
{
}
public override string ToString() => $"<Emoji> {Name}";
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace DiscordChatExporter.Core.Markdown.Ast
{
public class FormattedNode : Node
{
public TextFormatting Formatting { get; }
public IReadOnlyList<Node> Children { get; }
public FormattedNode(TextFormatting formatting, IReadOnlyList<Node> children)
{
Formatting = formatting;
Children = children;
}
public override string ToString() => $"<{Formatting}> ({Children.Count} direct children)";
}
}

View File

@@ -0,0 +1,14 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public class InlineCodeBlockNode : Node
{
public string Code { get; }
public InlineCodeBlockNode(string code)
{
Code = code;
}
public override string ToString() => $"<Code> {Code}";
}
}

View File

@@ -0,0 +1,22 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public class LinkNode : Node
{
public string Url { get; }
public string Title { get; }
public LinkNode(string url, string title)
{
Url = url;
Title = title;
}
public LinkNode(string url)
: this(url, url)
{
}
public override string ToString() => $"<Link> {Title}";
}
}

View File

@@ -0,0 +1,17 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public class MentionNode : Node
{
public string Id { get; }
public MentionType Type { get; }
public MentionNode(string id, MentionType type)
{
Id = id;
Type = type;
}
public override string ToString() => $"<{Type} mention> {Id}";
}
}

View File

@@ -0,0 +1,10 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public enum MentionType
{
Meta,
User,
Channel,
Role
}
}

View File

@@ -0,0 +1,17 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public class MultiLineCodeBlockNode : Node
{
public string Language { get; }
public string Code { get; }
public MultiLineCodeBlockNode(string language, string code)
{
Language = language;
Code = code;
}
public override string ToString() => $"<Code [{Language}]> {Code}";
}
}

View File

@@ -0,0 +1,6 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public abstract class Node
{
}
}

View File

@@ -0,0 +1,12 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public enum TextFormatting
{
Bold,
Italic,
Underline,
Strikethrough,
Spoiler,
Quote
}
}

View File

@@ -0,0 +1,14 @@
namespace DiscordChatExporter.Core.Markdown.Ast
{
public class TextNode : Node
{
public string Text { get; }
public TextNode(string text)
{
Text = text;
}
public override string ToString() => Text;
}
}