mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
updated to add advanced extensions to markdown
This commit is contained in:
@@ -6,7 +6,6 @@ using CanvasModel.Modules;
|
||||
using CanvasModel.Quizzes;
|
||||
using LocalModels;
|
||||
using Management.Services.Canvas;
|
||||
using Markdig.Renderers.Normalize;
|
||||
|
||||
namespace Management.Planner;
|
||||
|
||||
|
||||
@@ -15,16 +15,16 @@ public record AssignmentTemplate
|
||||
|
||||
return matches.Select(match => match.Groups[1].Value);
|
||||
}
|
||||
// public static string GetHtml(AssignmentTemplate template, LocalAssignment assignment)
|
||||
// public static string GetHtml(AssignmentTemplate template, LocalAssignment assignment)
|
||||
// {
|
||||
|
||||
// var html = Markdig.Markdown.ToHtml(template.Markdown);
|
||||
// var html = MarkdownService.Render(template.Markdown);
|
||||
|
||||
// foreach (KeyValuePair<string, string> entry in assignment.template_variables)
|
||||
// {
|
||||
// html = html.Replace($"%7B%7B{entry.Key}%7D%7D", entry.Value);
|
||||
// }
|
||||
// return html;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace LocalModels;
|
||||
|
||||
@@ -30,7 +25,7 @@ public record LocalAssignment : IModuleItem
|
||||
|
||||
public string GetDescriptionHtml()
|
||||
{
|
||||
return Markdig.Markdown.ToHtml(Description);
|
||||
return MarkdownService.Render(Description);
|
||||
}
|
||||
|
||||
public ulong? GetCanvasAssignmentGroupId(IEnumerable<LocalAssignmentGroup> assignmentGroups) =>
|
||||
|
||||
@@ -5,7 +5,7 @@ public record LocalCoursePage : IModuleItem
|
||||
public required string Name { get; init; }
|
||||
public required string Text { get; set; }
|
||||
public DateTime DueAt { get; init; }
|
||||
public string GetBodyHtml() => Markdig.Markdown.ToHtml(Text);
|
||||
public string GetBodyHtml() => MarkdownService.Render(Text);
|
||||
|
||||
public string ToMarkdown()
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ public record LocalQuiz : IModuleItem
|
||||
.FirstOrDefault(g => g.Name == LocalAssignmentGroupName)?
|
||||
.CanvasId;
|
||||
|
||||
public string GetDescriptionHtml() => Markdig.Markdown.ToHtml(Description);
|
||||
public string GetDescriptionHtml() => MarkdownService.Render(Description);
|
||||
|
||||
public string ToYaml()
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace LocalModels;
|
||||
public record LocalQuizQuestion
|
||||
{
|
||||
public string Text { get; init; } = string.Empty;
|
||||
public string HtmlText => Markdig.Markdown.ToHtml(Text);
|
||||
public string HtmlText => MarkdownService.Render(Text);
|
||||
public string QuestionType { get; init; } = string.Empty;
|
||||
public int Points { get; init; }
|
||||
public IEnumerable<LocalQuizQuestionAnswer> Answers { get; init; } =
|
||||
|
||||
@@ -10,7 +10,7 @@ public record LocalQuizQuestionAnswer
|
||||
|
||||
public string? MatchedText { get; init; }
|
||||
|
||||
public string HtmlText => Markdig.Markdown.ToHtml(Text);
|
||||
public string HtmlText => MarkdownService.Render(Text);
|
||||
|
||||
public static LocalQuizQuestionAnswer ParseMarkdown(string input, string questionType)
|
||||
{
|
||||
|
||||
13
Management/Services/MarkdownService.cs
Normal file
13
Management/Services/MarkdownService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Markdig;
|
||||
|
||||
|
||||
public static class MarkdownService
|
||||
{
|
||||
public static string Render(string incomingMarkdown)
|
||||
{
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.UseAdvancedExtensions()
|
||||
.Build();
|
||||
return Markdown.ToHtml(incomingMarkdown, pipeline);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user