build(aio): map H3 headings into H4 headings for certain templates (#24000)
The sections such as methods and decorator options are already headed by a H3 heading so we need to map the H3 headings in the API doc source down to H4 headings. This commit includes general heading mapping functionality accessible via the `marked` Nunjucks filter. PR Close #24000
This commit is contained in:

committed by
Miško Hevery

parent
232203242a
commit
20f9e51b8f
@ -95,4 +95,36 @@ describe('remark: renderMarkdown service', () => {
|
||||
'</code-example>\n'
|
||||
);
|
||||
});
|
||||
|
||||
it('should map heading levels as specified', () => {
|
||||
const content =
|
||||
'# heading 1\n' +
|
||||
'\n' +
|
||||
'some paragraph\n' +
|
||||
'\n' +
|
||||
'## heading 2a\n' +
|
||||
'\n' +
|
||||
'some paragraph\n' +
|
||||
'\n' +
|
||||
'### heading 3\n' +
|
||||
'\n' +
|
||||
'some paragraph\n' +
|
||||
'\n' +
|
||||
'## heading 2b\n' +
|
||||
'\n' +
|
||||
'some paragraph\n' +
|
||||
'\n';
|
||||
const headingMappings = { h2: 'h3', h3: 'h5' };
|
||||
const output = renderMarkdown(content, headingMappings);
|
||||
expect(output).toEqual(
|
||||
'<h1>heading 1</h1>\n' +
|
||||
'<p>some paragraph</p>\n' +
|
||||
'<h3>heading 2a</h3>\n' +
|
||||
'<p>some paragraph</p>\n' +
|
||||
'<h5>heading 3</h5>\n' +
|
||||
'<p>some paragraph</p>\n' +
|
||||
'<h3>heading 2b</h3>\n' +
|
||||
'<p>some paragraph</p>\n'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user