Snippet to regenerate table of content
trungdq88 opened this issue · comments
Tony Dinh commented
Run in the browser console while visiting your README.
$$('.markdown-body h2, .markdown-body h3, .markdown-body h4').map(heading => {
const text = heading.innerText
const hash = heading.querySelector('a').getAttribute('href');
const level = Number(heading.tagName.replace('H', '')) - 2;
const length = heading.nextElementSibling.querySelectorAll('tbody tr').length
const lengthText = length > 0 ? `(${length})` : ''
return `${new Array(level).fill(' ').join('')}- [${text} ${lengthText}](${hash})`;
}).join('\n')