File tree Expand file tree Collapse file tree 7 files changed +107
-217
lines changed
tests/Elastic.Markdown.Tests/FrontMatter Expand file tree Collapse file tree 7 files changed +107
-217
lines changed Original file line number Diff line number Diff line change 55using Elastic . Markdown . Diagnostics ;
66using Elastic . Markdown . Myst ;
77using Elastic . Markdown . Myst . Directives ;
8+ using Elastic . Markdown . Myst . FrontMatter ;
89using Elastic . Markdown . Slices ;
910using Markdig ;
1011using Markdig . Extensions . Yaml ;
Original file line number Diff line number Diff line change 44using System . IO . Abstractions ;
55using Elastic . Markdown . Diagnostics ;
66using Elastic . Markdown . IO ;
7+ using Elastic . Markdown . Myst . FrontMatter ;
78
89namespace Elastic . Markdown . Myst . Directives ;
910
Original file line number Diff line number Diff line change 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
4+
5+ using YamlDotNet . Serialization ;
6+
7+ namespace Elastic . Markdown . Myst . FrontMatter ;
8+
9+ [ YamlStaticContext ]
10+ public partial class YamlFrontMatterStaticContext ;
11+
12+ [ YamlSerializable ]
13+ public class YamlFrontMatter
14+ {
15+ [ YamlMember ( Alias = "title" ) ]
16+ public string ? Title { get ; set ; }
17+
18+ [ YamlMember ( Alias = "navigation_title" ) ]
19+ public string ? NavigationTitle { get ; set ; }
20+
21+ [ YamlMember ( Alias = "sub" ) ]
22+ public Dictionary < string , string > ? Properties { get ; set ; }
23+
24+
25+ [ YamlMember ( Alias = "applies" ) ]
26+ public Deployment ? AppliesTo { get ; set ; }
27+ }
28+
29+ public static class FrontMatterParser
30+ {
31+ public static YamlFrontMatter Deserialize ( string yaml )
32+ {
33+ var input = new StringReader ( yaml ) ;
34+
35+ var deserializer = new StaticDeserializerBuilder ( new YamlFrontMatterStaticContext ( ) )
36+ . IgnoreUnmatchedProperties ( )
37+ . WithTypeConverter ( new SemVersionConverter ( ) )
38+ . WithTypeConverter ( new DeploymentConverter ( ) )
39+ . Build ( ) ;
40+
41+ var frontMatter = deserializer . Deserialize < YamlFrontMatter > ( input ) ;
42+ return frontMatter ;
43+
44+ }
45+ }
46+
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 77using Elastic . Markdown . IO ;
88using Elastic . Markdown . Myst . Comments ;
99using Elastic . Markdown . Myst . Directives ;
10+ using Elastic . Markdown . Myst . FrontMatter ;
1011using Elastic . Markdown . Myst . InlineParsers ;
1112using Elastic . Markdown . Myst . Substitution ;
1213using Markdig ;
Original file line number Diff line number Diff line change 44
55using System . IO . Abstractions ;
66using Elastic . Markdown . IO ;
7+ using Elastic . Markdown . Myst . FrontMatter ;
78using Markdig ;
89using Markdig . Parsers ;
910
You can’t perform that action at this time.
0 commit comments