rendering html

This commit is contained in:
Paul Schneider
2025-02-23 20:59:07 +00:00
parent 7ccb9cd1da
commit b38f006658
3 changed files with 15 additions and 13 deletions

View File

@ -1,9 +1,6 @@
using System.Text;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using AsciiDocNet;
using Yavsc.Models.Blog;
using System.Linq.Expressions;
namespace Yavsc.Helpers
{
@ -51,7 +48,7 @@ namespace Yavsc.Helpers
Source source = (Source)elt;
// TODO syntact hilighting and fun js modules
contentbuilder.AppendHtmlLine("<pre><code>");
contentbuilder.Append(source.Text);
contentbuilder.AppendHtml(source.Text);
contentbuilder.AppendHtmlLine("</code></pre>");
break;
default:
@ -95,7 +92,7 @@ namespace Yavsc.Helpers
case "AsciiDocNet.Emphasis":
sb.AppendHtml("<i>");
AsciiDocNet.Emphasis em = (Emphasis)elt;
sb.Append(em.Text);
sb.AppendHtml(em.Text);
sb.AppendHtml("</i>");
break;
@ -150,9 +147,9 @@ namespace Yavsc.Helpers
var tl = elt as TextLiteral;
if (tl?.Attributes.Anchor != null)
{
sb.AppendFormat("<a name=\"{0}\">{1}</a> ", tl.Attributes.Anchor.Id, tl.Attributes.Anchor.XRefLabel);
sb.AppendHtmlLine($"<a name=\"{tl.Attributes.Anchor.Id}\">{tl.Attributes.Anchor.XRefLabel}</a> ");
}
if (tl != null) sb.Append(tl.Text);
if (tl != null) sb.AppendHtml(tl.Text);
}
public static IHtmlContent ToHtml(this Document doc, int doclevel = 4)
@ -176,7 +173,7 @@ namespace Yavsc.Helpers
return contentbuilder;
}
/*
public static IHtmlContent AsciiDocFor<TModel>(this IHtmlHelper<TModel> html,
Expression<Func<TModel, string>> expression)
{
@ -209,6 +206,6 @@ namespace Yavsc.Helpers
// Render tag
return builder.ToString();
}
} */
}
}

View File

@ -8,6 +8,10 @@ namespace Yavsc.Helpers
{
public override async Task ProcessAsync (TagHelperContext context, TagHelperOutput output)
{
if (context.AllAttributes.ContainsName ("summary"))
{
var summaryLength = context.AllAttributes["summary"].Value;
}
await base.ProcessAsync(context, output);
var content = await output.GetChildContentAsync();
string text = content.GetContent();

View File

@ -51,17 +51,18 @@
var title = group.Key ?? "@";
string secondclass="";
var first = group.First();
int maxTextLen = 256;
<tr><td colspan="3">
<a asp-action="Title" asp-route-id="@group.Key" >@title</a></td></tr>
@foreach (var item in group) {
var trunked = item.Content?.Length > 256;
var trunked = item.Content?.Length > maxTextLen;
<tr>
<td><a asp-action="Details" asp-route-id="@item.Id" class="bloglink">
<img src="@item.Photo" class="blogphoto"></a>
</td>
<td>
<asciidoc summary="256">@item.Content</asciidoc>
<asciidoc summary="@maxTextLen">@item.Content</asciidoc>
@if (trunked) { <a asp-action="Details" asp-route-id="@item.Id" class="bloglink">...</a> }
<span style="font-size:x-small;">@Html.DisplayFor(m => item.Author)</span>
<span style="font-size:xx-small;">