Summary length may be overflowed

vnext
Paul Schneider 4 years ago
parent f81f6617ce
commit a7f501c183
1 changed files with 16 additions and 5 deletions

@ -25,8 +25,8 @@ namespace Yavsc.TagHelpers
private const string MarkdownContentAttributeName = "markdown";
private const string MarkdownMarkAttributeName = "ismarkdown";
private const string SummaryMarkAttributeName = "summary";
[HtmlAttributeName("site")]
public SiteSettings Site { get; set; }
[HtmlAttributeName("site")]
public SiteSettings Site { get; set; }
[HtmlAttributeName("base")]
public string Base { get; set; }
@ -90,7 +90,18 @@ namespace Yavsc.TagHelpers
// Transform the supplied text (Markdown) into HTML.
var markdownTransformer = GetMarkdownTransformer();
markdownTransformer.UrlBaseLocation = urlBaseLocation;
// Si seul un sommaire est demandé,
// s'assurer que la longueur du contenu ne dépasse pas de trop la longueur indiquée
if (Summary > 0)
{
if (text.Length > Summary + 28)
{
text = text.Substring(0, Summary + 28);
}
}
string html = markdownTransformer.Transform(text);
// Wrap the html in an MvcHtmlString otherwise it'll be HtmlEncoded and displayed to the user as HTML :(
return html;
}

Loading…