Skip to content
Cloudflare

Rust streaming HTML parser/rewriter

Nov 29, 2019Andrew Galloni, Ivan Nikulin16 min read
Opens blog.cloudflare.com
What the post coversAI, from the source post

This post details the development of LOL HTML, a Rust-based streaming HTML rewriter/parser with a CSS-selector based API, which serves as the backend for Cloudflare Workers' HTMLRewriter.

  • It introduces a dual-parser architecture (lexer and tag scanner) to optimize performance by skipping non-matching content and avoiding expensive token propagation to the Workers runtime.
  • It also describes a Rust macro-based DSL for defining Nondeterministic finite automata for parsing and byte slice processing optimizations using token outlines for lazy transformation into byte slices.
Read the full post on blog.cloudflare.com · 16 min (opens in a new tab)

More from the Edge Computing with Cloudflare Workers trail