Skip to content

added html editor + url generator, new instructions syntax, compression - #1

Merged
midlan merged 19 commits into
masterfrom
claude/explain-codebase-mlqt5rg91gng32ut-qjKdY
Feb 18, 2026
Merged

midlan merged 19 commits into
masterfrom
claude/explain-codebase-mlqt5rg91gng32ut-qjKdY

Conversation

@midlan

@midlan midlan commented Feb 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR introduces DomBuilder, a system for compressing HTML into a compact instruction format, compressing it with deflate, and encoding it as base64url for use in URL hashes. It includes both a decoder for rendering compressed HTML and an editor for creating and sharing compressed HTML URLs.

Key Changes

  • New dombuilder.js module: Core library providing:

    • Instruction executor: Interprets a simple instruction set (E/A/T/^) to build DOM elements
    • HTML-to-instructions converter: Parses HTML and generates the instruction format
    • Compression/decompression: Uses CompressionStream API with deflate-raw
    • Base64url encoding/decoding: Converts compressed bytes to URL-safe strings
    • High-level encode/decode functions for end-to-end workflows
  • Simplified index.html: Replaced complex URL parameter parsing with:

    • Single hash-based decoder that reads compressed instructions from the URL fragment
    • Calls decodeInstructions() and executeInstructions() to render the DOM
    • Error handling for decode failures
  • New editor.html: Interactive editor for creating shareable URLs:

    • Split-pane UI with HTML source editor and live preview
    • "Run" button converts HTML → instructions → compressed URL
    • Displays the resulting shareable URL in a copy-friendly input field
    • Preview renders via the instruction executor for validation

Implementation Details

  • Instructions use a line-based format: E tag, A name value, T text, ^ (pop)
  • Text escaping: \\ for backslash, \n for newline
  • Compression via native CompressionStream API (deflate-raw format)
  • Base64url encoding removes padding and uses URL-safe characters
  • Both encoder and decoder are async to support streaming compression APIs

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s


Note

Medium Risk
Medium risk because it replaces the URL parsing/rendering mechanism and adds a custom compression/encoding pipeline plus new deployment automation, which could break existing links or Pages publishing if assumptions are wrong.

Overview
Switches the app from query-style hash parsing to a compressed instruction format stored in the URL hash, with index.html now decoding and executing instructions to rebuild the DOM at runtime.

Adds a new dombuilder.js core module (instruction executor, HTML→instruction conversion, deflate-raw compression, base64url encode/decode) and an editor.html split-panel editor that generates shareable URLs and previews output.

Updates GitHub Actions to deploy on tags into per-tag directories on gh-pages, maintain a /latest/ symlink, and generate a root release index; adds a Node 20 CI workflow that roundtrips encode/decode against example HTML fixtures. Updates README.md to document the new editor, encoding approach, and versioned deployments.

Written by Cursor Bugbot for commit 798ee9e. This will update automatically on new commits. Configure here.

- Replace URL-param DSL with line-based instruction format
  (E=element, A=attribute, T=text, ^=pop) for readability and
  better compression
- Add deflate-raw compression via CompressionStream + base64url
  encoding for compact URL fragments
- Extract shared logic into dombuilder.js (instruction executor,
  HTML-to-instructions converter, compress/decompress, base64url)
- Add editor.html: W3Schools-style try-it editor with HTML source
  textarea, live preview iframe, and generated URL output

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Each tag gets its own subdirectory on the gh-pages branch,
e.g. https://midlan.github.io/dombuilder/v1/editor.html.
Avoids environment protection rules by pushing to gh-pages
branch instead of using Actions-based deployment.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Comment thread dombuilder.js Resolved
Comment thread dombuilder.js Resolved
- Remove index.html from generated URLs so they look like /tag/#hash
- Add Copy button next to the URL bar in editor
- Rewrite README with editor docs and "How It Works" section

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
- Escape newlines and backslashes in attribute values when encoding
  A instructions, matching the escaping already done for T instructions.
  Unescaped newlines in attr values would corrupt the line-based
  instruction stream.
- Decode escape sequences when reading A instruction values.
- Preserve whitespace-only text nodes (e.g. space between inline
  elements) by checking text !== '' instead of text.trim() !== ''.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Test HTML examples: form, table, inline SVG, inline CSS, inline JS.
The test script reads each file, compresses it via encodeInstructions,
decompresses via decodeInstructions, and asserts the output matches
the original input.

GitHub Actions workflow runs the tests on every push and PR.
Tests dir is already excluded from gh-pages (deploy copies only
specific files).

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Comment thread dombuilder.js Resolved
Move appendChild from the E instruction to the ^ instruction so
elements are completely constructed (attributes, text, children)
before being inserted into the live DOM. This fixes inline <script>
execution — previously the empty script was appended first, causing
the browser to set the "already started" flag before any text content
was added, silently preventing execution.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
@midlan midlan changed the title Add DomBuilder: HTML compression and URL-based DOM generation added html editor/url generator, new instructions syntax, compression Feb 18, 2026
@midlan midlan changed the title added html editor/url generator, new instructions syntax, compression added html editor + url generator, new instructions syntax, compression Feb 18, 2026
Comment thread dombuilder.js Resolved
Check parent namespaceURI to detect SVG context and use
createElementNS for svg and its descendants. The root svg
element is matched by tag name; children inherit the namespace
from their parent. Without this, SVG elements were created in
the HTML namespace and silently failed to render.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Each deploy now copies files into a /latest/ directory alongside
the versioned directory, so /latest/ always points to the most
recent tag. The root index lists "latest" first with the actual
tag name. README example link updated to use /latest/.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Add .nojekyll to disable Jekyll processing so GitHub Pages
serves symlinks as-is. Replace the latest/ directory copy with
a real symlink pointing at the current tag directory.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Guard the latest symlink update with a regex check so only tags
matching ^v[0-9] update it. Test or ad-hoc tags still deploy to
their own directory but won't overwrite the latest pointer.
Updated README examples to use v1/v2 instead of test1.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
- sed the tag into <title> of index.html and editor.html during
  deploy so the browser tab shows which version is loaded.
- Remove tag name from the "latest" link in the root index —
  it just says "latest" now.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
- Match only exactly v<digits> (^v[0-9]+$) so tags like v3-test1
  don't update latest.
- If no latest symlink exists yet, any tag creates it so there's
  always a working latest link.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
Add DEPLOY_TAG constant to editor.html (null for local dev). At deploy
time, the workflow seds it to the actual tag. When set, the generated
DOM URL rewrites the path segment to the real version, so visitors
using /latest/editor.html get /v3/#data links, not /latest/#data.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
The old check (! -e _site/latest) only worked for the very first
deploy. Once test3 created latest, test4 couldn't overwrite it.

Now checks if latest currently points to a real version tag (v1, v2…).
If it doesn't (pointing to a test tag or missing), any tag can update
it. Once a real version is deployed, only version tags update latest.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
- Increase dombuilder link font size in editor toolbar
- Add play triangle to Run button
- Lowercase "dombuilder" on releases page with "Releases" subheading

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread dombuilder.js Resolved
claude and others added 2 commits February 18, 2026 04:01
htmlToInstructions was unconditionally lowercasing all tagName values.
HTML elements need this (DIV -> div) but SVG elements like clipPath,
foreignObject, linearGradient, textPath and fe* filters have camelCase
names that must be preserved, otherwise createElementNS produces
elements with wrong local names that don't render.

https://claude.ai/code/session_01CAZxB9pJJmC3nph4AjqG4s
@midlan
midlan merged commit f57ae0d into master Feb 18, 2026
2 checks passed
@midlan
midlan deleted the claude/explain-codebase-mlqt5rg91gng32ut-qjKdY branch February 18, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants