@@ -38,9 +38,11 @@ _headings("transforms and formats headings", async () => {
3838 contents : `### hello` ,
3939 data : {
4040 dir : "blog" ,
41+ docs_type : "docs" ,
4142 sections,
4243 section_stack : [ sections ] ,
4344 section_title : "section" ,
45+ base_level : 3 ,
4446 prev_level : 3 ,
4547 slugs : [ ] ,
4648 seen_slugs : new Map ( ) ,
@@ -64,9 +66,11 @@ _headings("transforms and formats multi-level headings", async () => {
6466` ,
6567 data : {
6668 dir : "blog" ,
69+ docs_type : "blog" ,
6770 sections,
6871 section_stack : [ sections ] ,
6972 section_title : "section" ,
73+ base_level : 3 ,
7074 prev_level : 3 ,
7175 slugs : [ ] ,
7276 seen_slugs : new Map ( ) ,
@@ -94,9 +98,11 @@ _headings("transforms and formats multi-level headings", async () => {
9498` ,
9599 data : {
96100 dir : "blog" ,
101+ docs_type : "blog" ,
97102 sections,
98103 section_stack : [ sections ] ,
99104 section_title : "section" ,
105+ base_level : 3 ,
100106 prev_level : 3 ,
101107 slugs : [ ] ,
102108 seen_slugs : new Map ( ) ,
@@ -107,13 +113,13 @@ _headings("transforms and formats multi-level headings", async () => {
107113
108114 assert . equal (
109115 output . contents ,
110- `<h3><span id="section-subsection-1 " class="offset-anchor"></span><a href="blog#section-subsection-1 " class="anchor" aria-hidden></a>subsection</h3>
111- <h4><span id="section-subsection-1- subsubsection" class="offset-anchor"></span><a href="blog#section-subsection-1 -subsubsection" class="anchor" aria-hidden></a>subsubsection</h4>
112- <h5><span id="section-subsection-1- subsubsection-subsubsubsection" class="offset-anchor" data-scrollignore></span><a href="blog#section-subsection-1 -subsubsection-subsubsubsection" class="anchor" aria-hidden></a>subsubsubsection</h5>`
116+ `<h3><span id="section-subsection" class="offset-anchor"></span><a href="blog#section-subsection" class="anchor" aria-hidden></a>subsection</h3>
117+ <h4><span id="section-subsection-subsubsection" class="offset-anchor"></span><a href="blog#section-subsection-subsubsection" class="anchor" aria-hidden></a>subsubsection</h4>
118+ <h5><span id="section-subsection-subsubsection-subsubsubsection" class="offset-anchor" data-scrollignore></span><a href="blog#section-subsection-subsubsection-subsubsubsection" class="anchor" aria-hidden></a>subsubsubsection</h5>`
113119 ) ;
114120} ) ;
115121
116- _headings . only ( "transforms and formats multi-level headings" , async ( ) => {
122+ _headings ( "transforms and formats multi-level headings" , async ( ) => {
117123 const sections : unknown [ ] = [ ] ;
118124 const src = vFile ( {
119125 contents : `### subsection
@@ -133,9 +139,11 @@ _headings.only("transforms and formats multi-level headings", async () => {
133139` ,
134140 data : {
135141 dir : "blog" ,
142+ docs_type : "blog" ,
136143 sections,
137144 section_stack : [ sections ] ,
138145 section_title : "section" ,
146+ base_level : 3 ,
139147 prev_level : 3 ,
140148 slugs : [ ] ,
141149 seen_slugs : new Map ( ) ,
@@ -156,6 +164,54 @@ _headings.only("transforms and formats multi-level headings", async () => {
156164 ) ;
157165} ) ;
158166
167+ _headings (
168+ "transforms and formats multi-level headings: level 2 headings" ,
169+ async ( ) => {
170+ const sections : unknown [ ] = [ ] ;
171+ const src = vFile ( {
172+ contents : `## subsection
173+
174+ ### subsubsection
175+
176+ #### subsubsubsection
177+
178+ ## one
179+
180+ ### two
181+
182+ #### three
183+
184+ ### four
185+
186+ ` ,
187+ data : {
188+ dir : "blog" ,
189+ docs_type : "blog" ,
190+ sections,
191+ section_stack : [ sections ] ,
192+ section_title : "section" ,
193+ base_level : 2 ,
194+ prev_level : 2 ,
195+ slugs : [ ] ,
196+ seen_slugs : new Map ( ) ,
197+ } ,
198+ } ) ;
199+
200+ const output = await linkify_only ( src ) ;
201+
202+ assert . equal (
203+ output . contents ,
204+ `<h2><span id="section-subsection" class="offset-anchor"></span><a href="blog#section-subsection" class="anchor" aria-hidden></a>subsection</h2>
205+ <h3><span id="section-subsection-subsubsection" class="offset-anchor"></span><a href="blog#section-subsection-subsubsection" class="anchor" aria-hidden></a>subsubsection</h3>
206+ <h4><span id="section-subsection-subsubsection-subsubsubsection" class="offset-anchor" data-scrollignore></span><a href="blog#section-subsection-subsubsection-subsubsubsection" class="anchor" aria-hidden></a>subsubsubsection</h4>
207+ <h2><span id="section-one" class="offset-anchor"></span><a href="blog#section-one" class="anchor" aria-hidden></a>one</h2>
208+ <h3><span id="section-one-two" class="offset-anchor"></span><a href="blog#section-one-two" class="anchor" aria-hidden></a>two</h3>
209+ <h4><span id="section-one-two-three" class="offset-anchor" data-scrollignore></span><a href="blog#section-one-two-three" class="anchor" aria-hidden></a>three</h4>
210+ <h3><span id="section-one-four" class="offset-anchor"></span><a href="blog#section-one-four" class="anchor" aria-hidden></a>four</h3>`
211+ ) ;
212+ }
213+ ) ;
214+
159215strip ( "strips leading level 1 headings" , async ( ) => {
160216 const src = `
161217
0 commit comments