File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 33// See the LICENSE file in the project root for more information
44
55namespace Elastic . Markdown . Helpers ;
6- public static class TitleNormalizer
6+
7+ public static class Markdown
78{
89 // 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 ( "*" , "" ) ;
10+ public static string StripMarkdown ( string markdown )
11+ {
12+ using var writer = new StringWriter ( ) ;
13+ Markdig . Markdown . ToPlainText ( markdown , writer ) ;
14+ return writer . ToString ( ) ;
15+ }
1116}
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public string? NavigationTitle
4949 get
5050 {
5151 var title = ! string . IsNullOrEmpty ( _navigationTitle ) ? _navigationTitle : Title ;
52- return string . IsNullOrEmpty ( title ) ? null : TitleNormalizer . Normalize ( title ) ;
52+ return string . IsNullOrEmpty ( title ) ? null : Helpers . Markdown . StripMarkdown ( title ) ;
5353 }
5454 private set => _navigationTitle = value ;
5555 }
@@ -163,7 +163,7 @@ private void ReadDocumentInstructions(MarkdownDocument document)
163163 . Select ( h => ( h . GetData ( "header" ) as string , h . GetData ( "anchor" ) as string ) )
164164 . Select ( h => new PageTocItem
165165 {
166- Heading = TitleNormalizer . Normalize ( h . Item1 ! ) ,
166+ Heading = Helpers . Markdown . StripMarkdown ( h . Item1 ! ) ,
167167 Slug = _slugHelper . GenerateSlug ( h . Item2 ?? h . Item1 )
168168 } )
169169 . ToList ( ) ;
You can’t perform that action at this time.
0 commit comments