Skip to content

Commit 921f8ea

Browse files
committed
Format and license
1 parent deeb33a commit 921f8ea

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespace Elastic.Markdown.Helpers;
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
24

3-
public static class TitleSanitizer
5+
namespace Elastic.Markdown.Helpers;
6+
public static class TitleNormalizer
47
{
5-
// Removes markdown formatting from the title and returns only the text
6-
// Currently, only support 'bold' and 'code' formatting
7-
public static string Sanitize(string title) => title.Replace("`", "").Replace("*", "");
8+
// Removes markdown formatting from the title and returns only the text
9+
// Currently, only support 'bold' and 'code' formatting
10+
public static string Normalize(string title) => title.Replace("`", "").Replace("*", "");
811
}

src/Elastic.Markdown/IO/MarkdownFile.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ public DocumentationGroup? Parent
4646
public string? Title { get; private set; }
4747
public string? NavigationTitle
4848
{
49-
get {
49+
get
50+
{
5051
var title = !string.IsNullOrEmpty(_navigationTitle) ? _navigationTitle : Title;
51-
return string.IsNullOrEmpty(title) ? null : TitleSanitizer.Sanitize(title);
52+
return string.IsNullOrEmpty(title) ? null : TitleNormalizer.Normalize(title);
5253
}
5354
private set => _navigationTitle = value;
5455
}
@@ -162,7 +163,7 @@ private void ReadDocumentInstructions(MarkdownDocument document)
162163
.Select(h => (h.GetData("header") as string, h.GetData("anchor") as string))
163164
.Select(h => new PageTocItem
164165
{
165-
Heading = TitleSanitizer.Sanitize(h.Item1!),
166+
Heading = TitleNormalizer.Normalize(h.Item1!),
166167
Slug = _slugHelper.GenerateSlug(h.Item2 ?? h.Item1)
167168
})
168169
.ToList();

src/Elastic.Markdown/Slices/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
};
1818
}
1919
<section id="elastic-docs-v3">
20-
@(new HtmlString(Markdown.ToHtml("# " + Model.Title)))
20+
<h1>@(new HtmlString(Markdown.ToHtml("#" + Model.Title)))</h1>
2121
@if (Model.Applies is not null)
2222
{
2323
await RenderPartialAsync(Applies.Create(Model.Applies));

0 commit comments

Comments
 (0)