Skip to content

Commit 8164556

Browse files
authored
Merge pull request #1584 from hawkeye116477/main
Allow to set class for markdown header
2 parents 97caba0 + 7fde6a2 commit 8164556

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{ $class := .Attributes.class }}
12
{{ $text := chomp .Text }}
23
{{ if site.Params.main.titleCase }}{{ $text = title $text }}{{ end }}
34

@@ -6,12 +7,12 @@
67
{{ end }}
78

89
{{ if and site.Params.navigation.anchor $text }}
9-
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="heading">
10+
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="heading {{ with $class }}{{.}}{{end}}">
1011
{{- $text | safeHTML -}}
1112
<a href="#{{ .Anchor | safeURL }}" aria-labelledby="{{ .Anchor | safeURL }}">
1213
{{- partial "assets/icon.html" (dict "icon" "fas link anchor") }}
1314
</a>
1415
</h{{ .Level }}>
1516
{{ else }}
16-
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ $text | safeHTML }}</h{{ .Level }}>
17+
<h{{ .Level }} id="{{ .Anchor | safeURL }}" {{ with $class }} class="{{.}}"{{end }}>{{ $text | safeHTML }}</h{{ .Level }}>
1718
{{ end }}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
{{ $class := .Attributes.class }}
12
{{ $text := chomp .Text }}
23
{{ if site.Params.main.titleCase }}{{ $text = (title ($text | htmlUnescape)) | htmlEscape }}{{ end }}
34

45
{{ if and site.Params.navigation.anchor $text }}
5-
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="heading">
6+
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="heading {{ with $class }}{{.}}{{end}}">
67
{{- $text | safeHTML -}}
78
<a href="#{{ .Anchor | safeURL }}" aria-labelledby="{{ .Anchor | safeURL }}">
89
{{- partial "assets/icon.html" (dict "icon" "fas link anchor") }}
910
</a>
1011
</h{{ .Level }}>
1112
{{ else }}
12-
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ $text | safeHTML }}</h{{ .Level }}>
13+
<h{{ .Level }} id="{{ .Anchor | safeURL }}" {{ with $class }} class="{{.}}"{{end }}>{{ $text | safeHTML }}</h{{ .Level }}>
1314
{{ end }}

0 commit comments

Comments
 (0)