mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
testing markdown storage and retrieval
This commit is contained in:
30
Management/Models/Local/Assignment/AssignmentTemplate.cs
Normal file
30
Management/Models/Local/Assignment/AssignmentTemplate.cs
Normal 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;
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user