Skip to content

Commit

Permalink
Update tasks related to HTML parsing with HTMLRewriter and CSS options
Browse files Browse the repository at this point in the history
This should allow me to trim down the project to focus only on the layout and rendering aspect and externalize the HTML and CSS handling somewhat.

I do not plan on adding JavaScript support but if I were do it I could either use the `vm` API or just Bun's `eval` or `Function` constructor. Maybe I could also bring in QuickJS with Bun's C support via TinyCC (TCC).
  • Loading branch information
TomasHubelbauer committed Oct 13, 2024
1 parent 26ae2e0 commit fa4ab37
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,27 @@ state; perhaps during the next Browser Jam, more improvements will be delivered.

## Tasks

### Look into using `HTMLRewriter` as a solution for HTML parsing
### Use my `HTMLRewriter`-based `DOMParser` and drop the custom HTML parser here

As in https://github.com/TomasHubelbauer/bun-domparser.
https://github.com/TomasHubelbauer/bun-domparser

### Look into using Bun's experimental CSS parser

https://bun.sh/blog/bun-v1.1.30#experimental-css-parsing-bundling

`HTMLRewriter` will also probably be usable to implement a basic query selector
engine by parsing the whole HTML and then parsing it again with the CSS selector
and comparing the two trees to see which nodes of the original tree match the
nodes of the selector-driven tree.

This should be combined with the usage of the `HTMLRewriter`-based `DOMParser` I
mention above.

### Improve the HTML parser to not set a node as `cursor` until fully closed

Note that this will become obsolete once I switch to my `DOMParser` based on the
`HTMLRewriter` API bundled with Bun.

Right now, I'm materializing nodes the moment their opening tag finishes parsing
which allows me to simplify the attribute parsing states, but results in an
unfaithful representation of the incomplete DOM tree (stuff that's not fully
Expand Down

0 comments on commit fa4ab37

Please sign in to comment.