testing markdown storage and retrieval

This commit is contained in:
2023-12-04 12:27:06 -07:00
parent 69f0b322b2
commit c6ce528ba1
23 changed files with 467 additions and 340 deletions

View File

@@ -0,0 +1,30 @@
using System.Text.RegularExpressions;
namespace LocalModels;
public record AssignmentTemplate
{
public string Id { get; set; } = String.Empty;
public string Name { get; set; } = String.Empty;
public string Markdown { get; set; } = String.Empty;
public static IEnumerable<string> GetVariables(string markdown)
{
string pattern = "{{(.*?)}}";
MatchCollection matches = Regex.Matches(markdown, pattern);
return matches.Select(match => match.Groups[1].Value);
}
// public static string GetHtml(AssignmentTemplate template, LocalAssignment assignment)
// {
// var html = Markdig.Markdown.ToHtml(template.Markdown);
// foreach (KeyValuePair<string, string> entry in assignment.template_variables)
// {
// html = html.Replace($"%7B%7B{entry.Key}%7D%7D", entry.Value);
// }
// return html;
// }
}