-
Notifications
You must be signed in to change notification settings - Fork 32
Fix inline code in left navigation and h1 rendering #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
deeb33a
921f8ea
19327bf
97f4c94
5e07657
15ee32d
101b0be
226d834
3c46f20
2b4e21d
4ddc4bb
e00d555
9131b38
910bb55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||
| // Licensed to Elasticsearch B.V under one or more agreements. | ||||||||||||||||||||
| // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||||||||||||||||||||
| // See the LICENSE file in the project root for more information | ||||||||||||||||||||
|
|
||||||||||||||||||||
| namespace Elastic.Markdown.Helpers; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public static class Markdown | ||||||||||||||||||||
| { | ||||||||||||||||||||
| public static string StripMarkdown(string markdown) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| using var writer = new StringWriter(); | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For funsies tried to see if pooling the private static readonly ObjectPool<StringBuilder> StringBuilderPool = new DefaultObjectPool<StringBuilder>(new StringBuilderPooledObjectPolicy());
public static string StripMarkdownPooled(string markdown)
{
var sb = StringBuilderPool.Get();
try
{
using var writer = new StringWriter(sb, CultureInfo.InvariantCulture);
Markdig.Markdown.ToPlainText(markdown, writer);
return writer.ToString().TrimEnd('\n');
}
finally
{
StringBuilderPool.Return(sb);
}
}
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting, thank you! How did you actually measure this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Benchmark dot Will add a general benchmarking project at some point in the next week so we can utilize this more. and: https://www.elastic.co/guide/en/ecs-logging/dotnet/current/benchmark-dotnet-data-shipper.html on CI 😄 |
||||||||||||||||||||
| Markdig.Markdown.ToPlainText(markdown, writer); | ||||||||||||||||||||
| return writer.ToString().TrimEnd('\n'); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -46,7 +46,11 @@ public DocumentationGroup? Parent | |||||
| public string? Title { get; private set; } | ||||||
|
||||||
| public string? NavigationTitle | ||||||
| { | ||||||
| get => !string.IsNullOrEmpty(_navigationTitle) ? _navigationTitle : Title; | ||||||
| get | ||||||
| { | ||||||
| var title = !string.IsNullOrEmpty(_navigationTitle) ? _navigationTitle : Title; | ||||||
| return string.IsNullOrEmpty(title) ? null : Helpers.Markdown.StripMarkdown(title); | ||||||
|
||||||
| return string.IsNullOrEmpty(title) ? null : Helpers.Markdown.StripMarkdown(title); | |
| return string.IsNullOrEmpty(title) ? null : title.StripMarkdown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strip once when setting instead of each time we get the property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm partial to making these extension methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4ddc4bb