Closed ppwwyyxx closed 8 months ago
I have a post with the following headings (there is no h3):
h2 h2 h2 h4 h4 h4 h4 h2
And I used the toc widget with depth=3. I printed tocObj from https://github.com/ppoffice/hexo-component-inferno/blob/fa580355c039fdbfbb66f9bd7bd298a56af575ab/src/view/widget/toc.jsx#L50 and it shows
depth=3
tocObj
[ { text: 'Registration', id: 'Registration', level: 2 }, { text: 'Pay for what you use', id: 'Pay-for-what-you-use', level: 2 }, { text: 'Global states', id: 'Global-states', level: 2 }, { text: 'Name conflicts', id: 'Name-conflicts', level: 4 }, { text: 'Overwrites', id: 'Overwrites', level: 4 }, { text: 'Pickle & multiprocessing', id: 'Pickle-multiprocessing', level: 4 }, { text: 'Obscure Provenance', id: 'Obscure-Provenance', level: 4 }, { text: 'Alternative: just use full qualname', id: 'Alternative-just-use-full-qualname', level: 2 } ]
However, when I print the return value of the getToc function, it's:
getToc
{ '1': { id: 'Registration', text: 'Registration', index: '1' }, '2': { id: 'Pay-for-what-you-use', text: 'Pay for what you use', index: '2' }, '3': { '1': { id: 'Obscure-Provenance', text: 'Obscure Provenance', index: '3.1' }, id: 'Global-states', text: 'Global states', index: '3' }, '4': { id: 'Alternative-just-use-full-qualname', text: 'Alternative: just use full qualname', index: '4' } }
So among the 4 h4s, only one is kept.
h4
I don't know what the intended behavior is (keep all h4? keep no h4? throw an error?), but the current behavior is probably not intended.
The ToC should now generate correct headings with the latest commit.
## title 0 ## title 1 #### title 2 #### title 3 #### title 4 ## title 5
I have a post with the following headings (there is no h3):
And I used the toc widget with
depth=3
. I printedtocObj
from https://github.com/ppoffice/hexo-component-inferno/blob/fa580355c039fdbfbb66f9bd7bd298a56af575ab/src/view/widget/toc.jsx#L50 and it showsHowever, when I print the return value of the
getToc
function, it's:So among the 4
h4
s, only one is kept.I don't know what the intended behavior is (keep all h4? keep no h4? throw an error?), but the current behavior is probably not intended.