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:
@@ -1,4 +1,4 @@
|
|||||||
@using Markdig
|
|
||||||
@using Management.Web.Shared.Components
|
@using Management.Web.Shared.Components
|
||||||
|
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
@@ -59,7 +59,13 @@
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MarkupString preview { get => (MarkupString)Markdown.ToHtml(assignmentContext?.Assignment?.Description ?? ""); }
|
private MarkupString preview { get
|
||||||
|
{
|
||||||
|
var pipeline = new MarkdownPipelineBuilder()
|
||||||
|
.UsePipeTables().Build();
|
||||||
|
return (MarkupString)Markdown.ToHtml(assignmentContext?.Assignment?.Description ?? "", pipeline);
|
||||||
|
}
|
||||||
|
}
|
||||||
private string HelpText()
|
private string HelpText()
|
||||||
{
|
{
|
||||||
var groupNames = string.Join("\n- " , planner.LocalCourse?.Settings.AssignmentGroups.Select(g => g.Name) ?? []);
|
var groupNames = string.Join("\n- " , planner.LocalCourse?.Settings.AssignmentGroups.Select(g => g.Name) ?? []);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine(Navigation.BaseUri + "SignalRHub");
|
@* Console.WriteLine(Navigation.BaseUri + "SignalRHub"); *@
|
||||||
hubConnection = new HubConnectionBuilder()
|
hubConnection = new HubConnectionBuilder()
|
||||||
.WithUrl(Navigation.BaseUri + "SignalRHub")
|
.WithUrl(Navigation.BaseUri + "SignalRHub")
|
||||||
.WithAutomaticReconnect()
|
.WithAutomaticReconnect()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
@using Markdig
|
|
||||||
@using Management.Web.Shared.Components
|
@using Management.Web.Shared.Components
|
||||||
|
|
||||||
@inject CoursePlanner planner
|
@inject CoursePlanner planner
|
||||||
|
|||||||
@@ -79,4 +79,3 @@
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
@* <MonacoEditorDemo /> *@
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
@using Markdig
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter, EditorRequired]
|
[Parameter, EditorRequired]
|
||||||
@@ -40,7 +39,7 @@ else
|
|||||||
{
|
{
|
||||||
@foreach(var answer in Question.Answers)
|
@foreach(var answer in Question.Answers)
|
||||||
{
|
{
|
||||||
string answerPreview = answer.HtmlText.StartsWith("<p>")
|
string answerPreview = answer.HtmlText.StartsWith("<p>")
|
||||||
? answer.HtmlText.Replace("<p>", "<p class='m-0'>")
|
? answer.HtmlText.Replace("<p>", "<p class='m-0'>")
|
||||||
: answer.HtmlText;
|
: answer.HtmlText;
|
||||||
|
|
||||||
@@ -48,16 +47,16 @@ else
|
|||||||
@if(answer.Correct)
|
@if(answer.Correct)
|
||||||
{
|
{
|
||||||
<svg
|
<svg
|
||||||
style="width: 1em;"
|
style="width: 1em;"
|
||||||
class="me-1 my-auto"
|
class="me-1 my-auto"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
fill="none"
|
fill="none"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
d="M4 12.6111L8.92308 17.5L20 6.5"
|
d="M4 12.6111L8.92308 17.5L20 6.5"
|
||||||
stroke="var(--bs-success)"
|
stroke="var(--bs-success)"
|
||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
stroke-linecap="round"
|
stroke-linecap="round"
|
||||||
stroke-linejoin="round"
|
stroke-linejoin="round"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
@@ -66,7 +65,7 @@ else
|
|||||||
{
|
{
|
||||||
<div
|
<div
|
||||||
class="me-1 my-auto"
|
class="me-1 my-auto"
|
||||||
style="width: 1em;"
|
style="width: 1em;"
|
||||||
>
|
>
|
||||||
@if(Question.QuestionType == QuestionType.MULTIPLE_ANSWERS)
|
@if(Question.QuestionType == QuestionType.MULTIPLE_ANSWERS)
|
||||||
{
|
{
|
||||||
@@ -78,5 +77,5 @@ else
|
|||||||
@((MarkupString)answerPreview)
|
@((MarkupString)answerPreview)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using CanvasModel.Modules;
|
|||||||
using CanvasModel.Quizzes;
|
using CanvasModel.Quizzes;
|
||||||
using LocalModels;
|
using LocalModels;
|
||||||
using Management.Services.Canvas;
|
using Management.Services.Canvas;
|
||||||
using Markdig.Renderers.Normalize;
|
|
||||||
|
|
||||||
namespace Management.Planner;
|
namespace Management.Planner;
|
||||||
|
|
||||||
|
|||||||
@@ -15,16 +15,16 @@ public record AssignmentTemplate
|
|||||||
|
|
||||||
return matches.Select(match => match.Groups[1].Value);
|
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)
|
// foreach (KeyValuePair<string, string> entry in assignment.template_variables)
|
||||||
// {
|
// {
|
||||||
// html = html.Replace($"%7B%7B{entry.Key}%7D%7D", entry.Value);
|
// html = html.Replace($"%7B%7B{entry.Key}%7D%7D", entry.Value);
|
||||||
// }
|
// }
|
||||||
// return html;
|
// 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;
|
namespace LocalModels;
|
||||||
|
|
||||||
@@ -30,7 +25,7 @@ public record LocalAssignment : IModuleItem
|
|||||||
|
|
||||||
public string GetDescriptionHtml()
|
public string GetDescriptionHtml()
|
||||||
{
|
{
|
||||||
return Markdig.Markdown.ToHtml(Description);
|
return MarkdownService.Render(Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong? GetCanvasAssignmentGroupId(IEnumerable<LocalAssignmentGroup> assignmentGroups) =>
|
public ulong? GetCanvasAssignmentGroupId(IEnumerable<LocalAssignmentGroup> assignmentGroups) =>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ public record LocalCoursePage : IModuleItem
|
|||||||
public required string Name { get; init; }
|
public required string Name { get; init; }
|
||||||
public required string Text { get; set; }
|
public required string Text { get; set; }
|
||||||
public DateTime DueAt { get; init; }
|
public DateTime DueAt { get; init; }
|
||||||
public string GetBodyHtml() => Markdig.Markdown.ToHtml(Text);
|
public string GetBodyHtml() => MarkdownService.Render(Text);
|
||||||
|
|
||||||
public string ToMarkdown()
|
public string ToMarkdown()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public record LocalQuiz : IModuleItem
|
|||||||
.FirstOrDefault(g => g.Name == LocalAssignmentGroupName)?
|
.FirstOrDefault(g => g.Name == LocalAssignmentGroupName)?
|
||||||
.CanvasId;
|
.CanvasId;
|
||||||
|
|
||||||
public string GetDescriptionHtml() => Markdig.Markdown.ToHtml(Description);
|
public string GetDescriptionHtml() => MarkdownService.Render(Description);
|
||||||
|
|
||||||
public string ToYaml()
|
public string ToYaml()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace LocalModels;
|
|||||||
public record LocalQuizQuestion
|
public record LocalQuizQuestion
|
||||||
{
|
{
|
||||||
public string Text { get; init; } = string.Empty;
|
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 string QuestionType { get; init; } = string.Empty;
|
||||||
public int Points { get; init; }
|
public int Points { get; init; }
|
||||||
public IEnumerable<LocalQuizQuestionAnswer> Answers { get; init; } =
|
public IEnumerable<LocalQuizQuestionAnswer> Answers { get; init; } =
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public record LocalQuizQuestionAnswer
|
|||||||
|
|
||||||
public string? MatchedText { get; init; }
|
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)
|
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