@@ -16,39 +16,39 @@ namespace Elastic.Markdown.Myst.InlineParsers;
1616public class RestrictedAutolinkInlineParser : InlineParser
1717{
1818
19- public RestrictedAutolinkInlineParser ( ) => OpeningCharacters = [ '<' ] ;
19+ public RestrictedAutolinkInlineParser ( ) => OpeningCharacters = [ '<' ] ;
2020
21- public required IReadOnlySet < string > AllowedTags { get ; init ; }
21+ public required IReadOnlySet < string > AllowedTags { get ; init ; }
2222
23- public override bool Match ( InlineProcessor processor , ref StringSlice slice )
24- {
25- var saved = slice ;
26- int line ;
27- int column ;
28- if ( LinkHelper . TryParseAutolink ( ref slice , out var link , out var isEmail ) )
29- {
30- processor . Inline = new AutolinkInline ( link )
31- {
32- IsEmail = isEmail ,
33- Span = new SourceSpan ( processor . GetSourcePosition ( saved . Start , out line , out column ) , processor . GetSourcePosition ( slice . Start - 1 ) ) ,
34- Line = line ,
35- Column = column
36- } ;
37- }
38- else
39- {
40- slice = saved ;
41- if ( ! HtmlHelper . TryParseHtmlTag ( ref slice , out var htmlTag ) )
42- return false ;
43- if ( ! AllowedTags . Contains ( htmlTag ) )
44- return false ;
45- processor . Inline = new HtmlInline ( htmlTag )
46- {
47- Span = new SourceSpan ( processor . GetSourcePosition ( saved . Start , out line , out column ) , processor . GetSourcePosition ( slice . Start - 1 ) ) ,
48- Line = line ,
49- Column = column
50- } ;
51- }
52- return true ;
53- }
23+ public override bool Match ( InlineProcessor processor , ref StringSlice slice )
24+ {
25+ var saved = slice ;
26+ int line ;
27+ int column ;
28+ if ( LinkHelper . TryParseAutolink ( ref slice , out var link , out var isEmail ) )
29+ {
30+ processor . Inline = new AutolinkInline ( link )
31+ {
32+ IsEmail = isEmail ,
33+ Span = new SourceSpan ( processor . GetSourcePosition ( saved . Start , out line , out column ) , processor . GetSourcePosition ( slice . Start - 1 ) ) ,
34+ Line = line ,
35+ Column = column
36+ } ;
37+ }
38+ else
39+ {
40+ slice = saved ;
41+ if ( ! HtmlHelper . TryParseHtmlTag ( ref slice , out var htmlTag ) )
42+ return false ;
43+ if ( ! AllowedTags . Contains ( htmlTag ) )
44+ return false ;
45+ processor . Inline = new HtmlInline ( htmlTag )
46+ {
47+ Span = new SourceSpan ( processor . GetSourcePosition ( saved . Start , out line , out column ) , processor . GetSourcePosition ( slice . Start - 1 ) ) ,
48+ Line = line ,
49+ Column = column
50+ } ;
51+ }
52+ return true ;
53+ }
5454}
0 commit comments