1
0
This commit is contained in:
Debug_pro
2026-06-07 18:19:53 +03:00
commit fb13e5a20a
33 changed files with 2382 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
using Markdig;
namespace SimpleWiki.Services;
public static class MarkdownService
{
private static readonly MarkdownPipeline Pipeline = new MarkdownPipelineBuilder()
.UseAdvancedExtensions()
.Build();
public static string ToHtmlDocument(string title, string markdown)
{
var htmlBody = Markdown.ToHtml(markdown ?? string.Empty, Pipeline);
return $@"<!DOCTYPE html>
<html style='background:#1E1E2E; color:#CDD6F4;'>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta name='color-scheme' content='dark' />
<style>
html, body {{
margin: 0 !important;
padding: 0 !important;
min-height: 100%;
background: #1E1E2E !important;
background-color: #1E1E2E !important;
color: #CDD6F4 !important;
font-family: 'Segoe UI', sans-serif;
}}
body {{
box-sizing: border-box;
padding: 0 !important;
line-height: 1.65;
}}
.page {{
min-height: 100vh;
padding: 24px;
background: #1E1E2E !important;
color: #CDD6F4 !important;
}}
* {{ box-sizing: border-box; }}
h1, h2, h3, h4, h5, h6 {{ color: #B4BEFE !important; margin-top: 0; }}
p, ul, ol, blockquote, table, pre {{ margin-top: 0; margin-bottom: 16px; color: #CDD6F4; }}
li, span, div {{ color: inherit; }}
a {{ color: #89B4FA !important; }}
a:visited {{ color: #B4BEFE !important; }}
code {{ background: #11111B; color: #F5E0DC; padding: 3px 6px; border-radius: 8px; }}
pre {{ background: #11111B; color: #F5E0DC; padding: 14px 16px; border-radius: 12px; overflow-x: auto; }}
pre code {{ background: transparent; padding: 0; }}
blockquote {{ border-left: 4px solid #89B4FA; padding-left: 12px; color: #A6ADC8 !important; }}
table {{ border-collapse: collapse; width: 100%; background: #181825; border-radius: 12px; overflow: hidden; }}
th, td {{ border: 1px solid #45475A; padding: 10px 12px; text-align: left; color: #CDD6F4; }}
th {{ background: #313244; color: #CDD6F4; }}
hr {{ border: none; border-top: 1px solid #45475A; margin: 24px 0; }}
img {{ max-width: 100%; height: auto; border-radius: 10px; }}
</style>
<title>{System.Net.WebUtility.HtmlEncode(title)}</title>
</head>
<body bgcolor='#1E1E2E' text='#CDD6F4'>
<div class='page'>
{htmlBody}
</div>
</body>
</html>";
}
}