mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 15:53:30 -07:00
Rename markdown Header to Heading to avoid ambiguity and for consistency with MD/HTML standards
This commit is contained in:
parent
30b447d2ae
commit
bf0d8ab31e
|
|
@ -89,20 +89,20 @@ internal partial class HtmlMarkdownVisitor : MarkdownVisitor
|
||||||
_buffer.Append(closingTag);
|
_buffer.Append(closingTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async ValueTask VisitHeaderAsync(
|
protected override async ValueTask VisitHeadingAsync(
|
||||||
HeaderNode header,
|
HeadingNode heading,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
_buffer.Append(
|
_buffer.Append(
|
||||||
// lang=html
|
// lang=html
|
||||||
$"<h{header.Level}>"
|
$"<h{heading.Level}>"
|
||||||
);
|
);
|
||||||
|
|
||||||
await VisitAsync(header.Children, cancellationToken);
|
await VisitAsync(heading.Children, cancellationToken);
|
||||||
|
|
||||||
_buffer.Append(
|
_buffer.Append(
|
||||||
// lang=html
|
// lang=html
|
||||||
$"</h{header.Level}>"
|
$"</h{heading.Level}>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Markdown;
|
namespace DiscordChatExporter.Core.Markdown;
|
||||||
|
|
||||||
internal record HeaderNode(
|
internal record HeadingNode(
|
||||||
int Level,
|
int Level,
|
||||||
IReadOnlyList<MarkdownNode> Children
|
IReadOnlyList<MarkdownNode> Children
|
||||||
) : MarkdownNode, IContainerNode;
|
) : MarkdownNode, IContainerNode;
|
||||||
|
|
@ -95,10 +95,10 @@ internal static partial class MarkdownParser
|
||||||
(s, m) => new FormattingNode(FormattingKind.Quote, Parse(s.Relocate(m.Groups[1])))
|
(s, m) => new FormattingNode(FormattingKind.Quote, Parse(s.Relocate(m.Groups[1])))
|
||||||
);
|
);
|
||||||
|
|
||||||
private static readonly IMatcher<MarkdownNode> HeaderNodeMatcher = new RegexMatcher<MarkdownNode>(
|
private static readonly IMatcher<MarkdownNode> HeadingNodeMatcher = new RegexMatcher<MarkdownNode>(
|
||||||
// Consume the linebreak so that it's not attached to following nodes.
|
// Consume the linebreak so that it's not attached to following nodes.
|
||||||
new Regex(@"^(\#{1,3})\s(.+)\n", DefaultRegexOptions),
|
new Regex(@"^(\#{1,3})\s(.+)\n", DefaultRegexOptions),
|
||||||
(s, m) => new HeaderNode(m.Groups[1].Length, Parse(s.Relocate(m.Groups[2])))
|
(s, m) => new HeadingNode(m.Groups[1].Length, Parse(s.Relocate(m.Groups[2])))
|
||||||
);
|
);
|
||||||
|
|
||||||
private static readonly IMatcher<MarkdownNode> ListNodeMatcher = new RegexMatcher<MarkdownNode>(
|
private static readonly IMatcher<MarkdownNode> ListNodeMatcher = new RegexMatcher<MarkdownNode>(
|
||||||
|
|
@ -330,7 +330,7 @@ internal static partial class MarkdownParser
|
||||||
MultiLineQuoteNodeMatcher,
|
MultiLineQuoteNodeMatcher,
|
||||||
RepeatedSingleLineQuoteNodeMatcher,
|
RepeatedSingleLineQuoteNodeMatcher,
|
||||||
SingleLineQuoteNodeMatcher,
|
SingleLineQuoteNodeMatcher,
|
||||||
HeaderNodeMatcher,
|
HeadingNodeMatcher,
|
||||||
ListNodeMatcher,
|
ListNodeMatcher,
|
||||||
|
|
||||||
// Code blocks
|
// Code blocks
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ internal abstract class MarkdownVisitor
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
await VisitAsync(formatting.Children, cancellationToken);
|
await VisitAsync(formatting.Children, cancellationToken);
|
||||||
|
|
||||||
protected virtual async ValueTask VisitHeaderAsync(
|
protected virtual async ValueTask VisitHeadingAsync(
|
||||||
HeaderNode header,
|
HeadingNode heading,
|
||||||
CancellationToken cancellationToken = default) =>
|
CancellationToken cancellationToken = default) =>
|
||||||
await VisitAsync(header.Children, cancellationToken);
|
await VisitAsync(heading.Children, cancellationToken);
|
||||||
|
|
||||||
protected virtual async ValueTask VisitListAsync(
|
protected virtual async ValueTask VisitListAsync(
|
||||||
ListNode list,
|
ListNode list,
|
||||||
|
|
@ -72,9 +72,9 @@ internal abstract class MarkdownVisitor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node is HeaderNode header)
|
if (node is HeadingNode heading)
|
||||||
{
|
{
|
||||||
await VisitHeaderAsync(header, cancellationToken);
|
await VisitHeadingAsync(heading, cancellationToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue