Summary length may be overflowed

main
Paul Schneider 5 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 MarkdownContentAttributeName = "markdown";
private const string MarkdownMarkAttributeName = "ismarkdown"; private const string MarkdownMarkAttributeName = "ismarkdown";
private const string SummaryMarkAttributeName = "summary"; private const string SummaryMarkAttributeName = "summary";
[HtmlAttributeName("site")] [HtmlAttributeName("site")]
public SiteSettings Site { get; set; } public SiteSettings Site { get; set; }
[HtmlAttributeName("base")] [HtmlAttributeName("base")]
public string Base { get; set; } public string Base { get; set; }
@ -90,7 +90,18 @@ namespace Yavsc.TagHelpers
// Transform the supplied text (Markdown) into HTML. // Transform the supplied text (Markdown) into HTML.
var markdownTransformer = GetMarkdownTransformer(); var markdownTransformer = GetMarkdownTransformer();
markdownTransformer.UrlBaseLocation = urlBaseLocation; 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); string html = markdownTransformer.Transform(text);
// Wrap the html in an MvcHtmlString otherwise it'll be HtmlEncoded and displayed to the user as HTML :( // Wrap the html in an MvcHtmlString otherwise it'll be HtmlEncoded and displayed to the user as HTML :(
return html; return html;
} }

Loading…