@@ -27,26 +27,7 @@ public MyHeading(HeadingBlock headingBlock, MarkdownConfig config)
27
27
_paragraph = new Paragraph ( ) ;
28
28
_config = config ;
29
29
30
- var level = headingBlock . Level ;
31
- _paragraph . FontSize = level switch
32
- {
33
- 1 => _config . Themes . H1FontSize ,
34
- 2 => _config . Themes . H2FontSize ,
35
- 3 => _config . Themes . H3FontSize ,
36
- 4 => _config . Themes . H4FontSize ,
37
- 5 => _config . Themes . H5FontSize ,
38
- _ => _config . Themes . H6FontSize ,
39
- } ;
40
- _paragraph . Foreground = _config . Themes . HeadingForeground ;
41
- _paragraph . FontWeight = level switch
42
- {
43
- 1 => _config . Themes . H1FontWeight ,
44
- 2 => _config . Themes . H2FontWeight ,
45
- 3 => _config . Themes . H3FontWeight ,
46
- 4 => _config . Themes . H4FontWeight ,
47
- 5 => _config . Themes . H5FontWeight ,
48
- _ => _config . Themes . H6FontWeight ,
49
- } ;
30
+ SetHProperties ( headingBlock . Level ) ;
50
31
}
51
32
52
33
public MyHeading ( HtmlNode htmlNode , MarkdownConfig config )
@@ -65,7 +46,11 @@ public MyHeading(HtmlNode htmlNode, MarkdownConfig config)
65
46
_ => TextAlignment . Left ,
66
47
} ;
67
48
68
- var level = int . Parse ( htmlNode . Name . Substring ( 1 ) ) ;
49
+ SetHProperties ( int . Parse ( htmlNode . Name . Substring ( 1 ) ) ) ;
50
+ }
51
+
52
+ private void SetHProperties ( int level )
53
+ {
69
54
_paragraph . FontSize = level switch
70
55
{
71
56
1 => _config . Themes . H1FontSize ,
@@ -85,6 +70,15 @@ public MyHeading(HtmlNode htmlNode, MarkdownConfig config)
85
70
5 => _config . Themes . H5FontWeight ,
86
71
_ => _config . Themes . H6FontWeight ,
87
72
} ;
73
+ _paragraph . Margin = level switch
74
+ {
75
+ 1 => _config . Themes . H1Margin ,
76
+ 2 => _config . Themes . H2Margin ,
77
+ 3 => _config . Themes . H3Margin ,
78
+ 4 => _config . Themes . H4Margin ,
79
+ 5 => _config . Themes . H5Margin ,
80
+ _ => _config . Themes . H6Margin ,
81
+ } ;
88
82
}
89
83
90
84
public void AddChild ( IAddChild child )
0 commit comments