govuk-design-system icon indicating copy to clipboard operation
govuk-design-system copied to clipboard

Extract heading IDs using `getHeadingList()` from Marked

Open colinrotherham opened this issue 1 year ago • 1 comments

Context

Our Markdown heading ID plugin marked-gfm-heading-id has been updated with a new new export getHeadingList() which means we could remove extractPageHeadings() in future

Raising this issue so we don't lose track of it

Additional information (if applicable)

  • https://github.com/markedjs/marked-gfm-heading-id/pull/413
  • https://github.com/alphagov/govuk-design-system/pull/3167#issuecomment-1733615390

colinrotherham avatar Sep 25 '23 12:09 colinrotherham

I had a look at this from the perspective of getting rid of the extractPageHeadings plugin.

getHeadingList is only useful/available within the marked call, so there's some scoping issues getting it to work within the metalsmith-markdown call in the metalsmith build (and thus avoid the need to loop the files again).

By the time I had it starting to work, I was pretty deep in the weeds with closures and the like, and had generated a lot of extra code, which made it seem like either a bigger piece of work (I didn't get near testing everything), or something I'd need to start over on.

I then got distracted by cycle work and forgot this task existed, so I'll unassign myself for now. Maybe fresh eyes will spot a simpler way to get it working.

domoscargin avatar Apr 18 '24 06:04 domoscargin

Closed by #3793.

patrickpatrickpatrick avatar May 16 '24 13:05 patrickpatrickpatrick