This commit is contained in:
shump
2026-01-15 11:11:42 -06:00
commit 7562a4ce14
67 changed files with 5636 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Markdig.Syntax;
namespace MarkdownEditor.Views.Renderers;
/// <summary>
/// Renders markdown thematic breaks (horizontal rules).
/// </summary>
public class ThematicBreakRenderer : IMarkdownBlockRenderer
{
private readonly bool _isDarkMode;
/// <summary>
/// Initializes a new instance of the <see cref="ThematicBreakRenderer"/> class.
/// </summary>
/// <param name="isDarkMode">Whether the current theme is dark mode.</param>
public ThematicBreakRenderer(bool isDarkMode = true)
{
_isDarkMode = isDarkMode;
}
/// <inheritdoc/>
public bool CanRender(Block block) => block is ThematicBreakBlock;
/// <inheritdoc/>
public Control? Render(Block block)
{
if (block is not ThematicBreakBlock)
{
return null;
}
return new Border
{
BorderBrush = new SolidColorBrush(Color.Parse(_isDarkMode ? "#555555" : "#CCCCCC")),
BorderThickness = new Thickness(0, 1, 0, 0),
Margin = new Thickness(0, 10, 0, 10),
Height = 1
};
}
}