Skip to content
TriedPrompts

More in Migrations & upgrades.

Port an HTML5 parser from Python to JavaScript with Codex CLI

Codex CLI ran largely unattended for about 4.5 hours and produced 9,000 lines of JavaScript passing 9,200 html5lib tests.

Result: WorkedTool: OpenAI Codex CLILevel: AdvancedSetup: Needs Python

Copy the prompt

Outcome

Codex CLI (GPT-5.2) ran largely unattended for about 4.5 hours start to finish and produced about 9,000 lines of dependency-free JavaScript passing 9,200 html5lib tests. It took eight prompts in total. On a $20-a-month ChatGPT Plus plan, Codex paused when the plan's five-hour allowance ran out at 6:35 p.m., resumed after the 7:14 p.m. reset and declared itself done at 9:30 p.m., with the code in 43 commits. In its final test run, 1,770 of 1,782 tree-building tests passed and 12 were skipped. The author estimates the tokens would have cost $29.41 at API prices, but they were included in the subscription.

Poster says: Passes 9,200 html5lib tests

This is the source's own number. We haven't measured it.

Evidence: Screenshots or logsThe source shows screenshots, a transcript or the AI's output.

WorkedEvidence: Screenshots or logsPosted Last checked

Level: Advanced. You need: A tool that takes actions for you or writes code, connected accounts, or some setup on your computer.

How to use this

  1. Tap Copy prompt.
  2. Open the tool the case used (or a similar one) and paste the prompt; results may differ from the original.
  3. Paste it into the message box.
  4. Send it, then read the answer before acting on it.
New to this? What's a prompt?

A prompt is the message you send to the AI tool. Copy the one on this page, put your own details where it asks, and read the answer before you act on it.

Prompt

Original prompt

The prompt as the person shared it in the source.

What the prompt labels mean

These are the person's own words, as shared in the source.

We are going to create a JavaScript port of ~/dev/justhtml - an HTML parsing library that passes the full ~/dev/html5lib-tests test suite. It is going to have a similar API to the Python library but in JavaScript. It will have no dependencies other than raw JavaScript, hence it will work great in the browser and node.js and other environments. Start by reading ~/dev/justhtml and designing the user-facing API for the new library - create a spec.md containing your plan.

Try this in:

Sends the Original prompt shown above. ChatGPT and Grok open with it filled in, and ChatGPT may send it straight away. Gemini and Claude open empty, so we copy the prompt for you to paste. Every button also copies it.

Opens in a new tab. We don't see what you send.

These links are only a shortcut. We're not affiliated with OpenAI, Google, Anthropic or xAI, and your results may not match the source.

Optional stronger version

Our rewrite with extra checks. The poster didn't test it.

Goal: Create a dependency-free JavaScript port of ~/dev/justhtml that passes the full html5lib-tests suite.

Inputs (fill in or confirm):
- Source library path (~/dev/justhtml)
- Test suite path (~/dev/html5lib-tests)
- Target runtimes (browser and Node.js)

Rules:
- Mirror the Python API and module structure so behavior can be compared file by file.
- Wire up the test runner first, then port until test counts climb; commit at milestones.
- Keep a progress log: tests passing per category after each session.
- Commit after each milestone with the current pass count in the message.
- Keep zero runtime dependencies; flag any place you'd want one.
- Write a short README with usage for browser and Node.

Checkpoint: Ask before deleting or rewriting large sections that already pass tests.

If you get stuck: If a test category stalls, write down the failing cases and move on; come back after. If a login, CAPTCHA or two-step code appears, stop and ask me to handle it; never guess or store passwords.

Verify before you finish: Run the full suite in Node and a quick smoke test in a browser.

Output: The port, the runner, the progress log and the final pass count.

Done when: the full html5lib test suite passes in Node with no dependencies.

AI tool

OpenAI Codex CLI

Source

Posted
by Simon Willison
Last checked
Method:
How we verify

https://simonwillison.net/2025/Dec/15/porting-justhtml/

Tell us how it went A reader message. It is not published on this page, and it is not a test of the prompt.

More in Migrations & upgrades

More in CodingRandom case in Coding