mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-23 11:16:59 -04:00
parent
ffdca7b799
commit
77366cc9b4
1 changed files with 23 additions and 5 deletions
|
@ -140,6 +140,12 @@ namespace DiscordChatExporter.Core.Markdown
|
||||||
@"¯\_(ツ)_/¯",
|
@"¯\_(ツ)_/¯",
|
||||||
s => new TextNode(s));
|
s => new TextNode(s));
|
||||||
|
|
||||||
|
// Capture some specific emojis that don't get rendered
|
||||||
|
// This escapes it from matching for emoji
|
||||||
|
private static readonly IMatcher<Node> IgnoredEmojiTextNodeMatcher = new RegexMatcher<Node>(
|
||||||
|
new Regex("(\\u26A7|\\u2640|\\u2642|\\u2695|\\u267E|\\u00A9|\\u00AE|\\u2122)", DefaultRegexOptions),
|
||||||
|
m => new TextNode(m.Value, m.Groups[1].Value));
|
||||||
|
|
||||||
// Capture any "symbol/other" character or surrogate pair preceeded by a backslash
|
// Capture any "symbol/other" character or surrogate pair preceeded by a backslash
|
||||||
// This escapes it from matching for emoji
|
// This escapes it from matching for emoji
|
||||||
private static readonly IMatcher<Node> EscapedSymbolTextNodeMatcher = new RegexMatcher<Node>(
|
private static readonly IMatcher<Node> EscapedSymbolTextNodeMatcher = new RegexMatcher<Node>(
|
||||||
|
@ -155,6 +161,13 @@ namespace DiscordChatExporter.Core.Markdown
|
||||||
// Combine all matchers into one
|
// Combine all matchers into one
|
||||||
// Matchers that have similar patterns are ordered from most specific to least specific
|
// Matchers that have similar patterns are ordered from most specific to least specific
|
||||||
private static readonly IMatcher<Node> AggregateNodeMatcher = new AggregateMatcher<Node>(
|
private static readonly IMatcher<Node> AggregateNodeMatcher = new AggregateMatcher<Node>(
|
||||||
|
// Escaped text
|
||||||
|
ShrugTextNodeMatcher,
|
||||||
|
IgnoredEmojiTextNodeMatcher,
|
||||||
|
EscapedSymbolTextNodeMatcher,
|
||||||
|
EscapedCharacterTextNodeMatcher,
|
||||||
|
|
||||||
|
// Formatting
|
||||||
ItalicBoldFormattedNodeMatcher,
|
ItalicBoldFormattedNodeMatcher,
|
||||||
ItalicUnderlineFormattedNodeMatcher,
|
ItalicUnderlineFormattedNodeMatcher,
|
||||||
BoldFormattedNodeMatcher,
|
BoldFormattedNodeMatcher,
|
||||||
|
@ -163,21 +176,26 @@ namespace DiscordChatExporter.Core.Markdown
|
||||||
ItalicAltFormattedNodeMatcher,
|
ItalicAltFormattedNodeMatcher,
|
||||||
StrikethroughFormattedNodeMatcher,
|
StrikethroughFormattedNodeMatcher,
|
||||||
SpoilerFormattedNodeMatcher,
|
SpoilerFormattedNodeMatcher,
|
||||||
|
|
||||||
|
// Code blocks
|
||||||
MultilineCodeBlockNodeMatcher,
|
MultilineCodeBlockNodeMatcher,
|
||||||
InlineCodeBlockNodeMatcher,
|
InlineCodeBlockNodeMatcher,
|
||||||
|
|
||||||
|
// Mentions
|
||||||
EveryoneMentionNodeMatcher,
|
EveryoneMentionNodeMatcher,
|
||||||
HereMentionNodeMatcher,
|
HereMentionNodeMatcher,
|
||||||
UserMentionNodeMatcher,
|
UserMentionNodeMatcher,
|
||||||
ChannelMentionNodeMatcher,
|
ChannelMentionNodeMatcher,
|
||||||
RoleMentionNodeMatcher,
|
RoleMentionNodeMatcher,
|
||||||
StandardEmojiNodeMatcher,
|
|
||||||
CustomEmojiNodeMatcher,
|
// Links
|
||||||
TitledLinkNodeMatcher,
|
TitledLinkNodeMatcher,
|
||||||
AutoLinkNodeMatcher,
|
AutoLinkNodeMatcher,
|
||||||
HiddenLinkNodeMatcher,
|
HiddenLinkNodeMatcher,
|
||||||
ShrugTextNodeMatcher,
|
|
||||||
EscapedSymbolTextNodeMatcher,
|
// Emoji
|
||||||
EscapedCharacterTextNodeMatcher);
|
StandardEmojiNodeMatcher,
|
||||||
|
CustomEmojiNodeMatcher);
|
||||||
|
|
||||||
private static IReadOnlyList<Node> Parse(string input, IMatcher<Node> matcher) =>
|
private static IReadOnlyList<Node> Parse(string input, IMatcher<Node> matcher) =>
|
||||||
matcher.MatchAll(input, s => new TextNode(s)).Select(r => r.Value).ToArray();
|
matcher.MatchAll(input, s => new TextNode(s)).Select(r => r.Value).ToArray();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue