Skip to content

Instantly share code, notes, and snippets.

@simonw

simonw/prompt.md Secret

Created December 16, 2024 18:25
Show Gist options
  • Save simonw/ae27a3b2709d5412f4cb32ae99428099 to your computer and use it in GitHub Desktop.
Save simonw/ae27a3b2709d5412f4cb32ae99428099 to your computer and use it in GitHub Desktop.

No React, just HTML + CSS + JavaScript - build a tool where I can paste in HTML in a textarea and a URL to that page in a single line input

It then parses that HTML and finds all HTML headers within it. Any that do not yet have an ID attribute have a unique one assigned to them based on the text of that heading (lowercase, spaces converted to hyphens, other characters removed)

The tool outputs two things in two new textareas: the new updated HTML with the extra ID attributes, and then a separate textarea with the following HTML - one list item for each heading:

<ul>
  <li><a href="that-URL-the-user-provided#heading-id">Heading text</a></li>
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment