mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-04-29 09:12:40 +00:00
Rework markdown parser and improve its performance for non-HTML formats
This commit is contained in:
@@ -12,16 +12,15 @@ namespace DiscordChatExporter.Core.Markdown.Nodes
|
||||
|
||||
public bool IsCustomEmoji => !Id.IsNullOrWhiteSpace();
|
||||
|
||||
public EmojiNode(string source, string id, string name, bool isAnimated)
|
||||
: base(source)
|
||||
public EmojiNode(string id, string name, bool isAnimated)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
IsAnimated = isAnimated;
|
||||
}
|
||||
|
||||
public EmojiNode(string source, string name)
|
||||
: this(source, null, name, false)
|
||||
public EmojiNode(string name)
|
||||
: this(null, name, false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,12 @@ namespace DiscordChatExporter.Core.Markdown.Nodes
|
||||
{
|
||||
public class FormattedNode : Node
|
||||
{
|
||||
public string Token { get; }
|
||||
|
||||
public TextFormatting Formatting { get; }
|
||||
|
||||
public IReadOnlyList<Node> Children { get; }
|
||||
|
||||
public FormattedNode(string source, string token, TextFormatting formatting, IReadOnlyList<Node> children)
|
||||
: base(source)
|
||||
public FormattedNode(TextFormatting formatting, IReadOnlyList<Node> children)
|
||||
{
|
||||
Token = token;
|
||||
Formatting = formatting;
|
||||
Children = children;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
{
|
||||
public string Code { get; }
|
||||
|
||||
public InlineCodeBlockNode(string source, string code)
|
||||
: base(source)
|
||||
public InlineCodeBlockNode(string code)
|
||||
{
|
||||
Code = code;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
|
||||
public string Title { get; }
|
||||
|
||||
public LinkNode(string source, string url, string title)
|
||||
: base(source)
|
||||
public LinkNode(string url, string title)
|
||||
{
|
||||
Url = url;
|
||||
Title = title;
|
||||
}
|
||||
|
||||
public LinkNode(string source, string url) : this(source, url, url)
|
||||
public LinkNode(string url)
|
||||
: this(url, url)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
public MentionType Type { get; }
|
||||
|
||||
public MentionNode(string source, string id, MentionType type)
|
||||
: base(source)
|
||||
public MentionNode(string id, MentionType type)
|
||||
{
|
||||
Id = id;
|
||||
Type = type;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
namespace DiscordChatExporter.Core.Markdown.Nodes
|
||||
{
|
||||
public class MultilineCodeBlockNode : Node
|
||||
public class MultiLineCodeBlockNode : Node
|
||||
{
|
||||
public string Language { get; }
|
||||
|
||||
public string Code { get; }
|
||||
|
||||
public MultilineCodeBlockNode(string source, string language, string code)
|
||||
: base(source)
|
||||
public MultiLineCodeBlockNode(string language, string code)
|
||||
{
|
||||
Language = language;
|
||||
Code = code;
|
||||
@@ -2,11 +2,5 @@
|
||||
{
|
||||
public abstract class Node
|
||||
{
|
||||
public string Source { get; }
|
||||
|
||||
protected Node(string source)
|
||||
{
|
||||
Source = source;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,11 @@
|
||||
{
|
||||
public string Text { get; }
|
||||
|
||||
public TextNode(string source, string text)
|
||||
: base(source)
|
||||
public TextNode(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public TextNode(string text) : this(text, text)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user