Skip to content

Instantly share code, notes, and snippets.

@maxpatiiuk
Created August 23, 2022 18:19
Show Gist options
  • Save maxpatiiuk/e7b6d3a397850af96a328e0723236e4d to your computer and use it in GitHub Desktop.
Save maxpatiiuk/e7b6d3a397850af96a328e0723236e4d to your computer and use it in GitHub Desktop.
Convert Github Issue list to a markdown changelog
extractNumber = (href)=>href.match(/issues\/(?<number>\d+)/)?.groups.number;
categories = $$('a.markdown-title').map(v=>{
const href = v.href;
const title = v.textContent;
const number = extractNumber(href);
const formattedNumber = typeof number === 'string' ? `#${number}` : href;
const isBug = v.nextElementSibling.textContent.includes('type:bug');
return [isBug ? 'Fixed' : 'Added',`- ${title} ([${formattedNumber}](${href}))`];
}).reduce((total, [type,line])=>{
total[type] ??= [];
total[type].push(line);
return total;
}, {});
Object.entries(categories)
.map(([label, lines])=>`### ${label}\n\n${lines.join('\n')}`).join('\n\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment