mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-03 11:22:30 +02:00
Fix anchors erroring when heading is empty (#772)
This commit is contained in:
parent
850e3003ca
commit
371fdda4a8
2 changed files with 26 additions and 11 deletions
|
@ -6,10 +6,13 @@
|
|||
*/
|
||||
|
||||
const anchors = require('../anchors');
|
||||
const rules = require('remarkable/lib/rules');
|
||||
|
||||
const md = {
|
||||
renderer: {
|
||||
rules: {},
|
||||
rules: {
|
||||
heading_open: rules.heading_open,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -109,3 +112,8 @@ test('Anchor index resets on each render', () => {
|
|||
'id="almost-unique-heading-1"'
|
||||
);
|
||||
});
|
||||
|
||||
test('Anchor uses default renderer when empty', () => {
|
||||
expect(render([{hLevel: 1}, {content: null}], 0, {}, {})).toEqual('<h1>');
|
||||
expect(render([{hLevel: 2}, {content: ''}], 0, {}, {})).toEqual('<h2>');
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue