Skip to content

Contributing

Pages Parsec parses differently from a browser, selectors it gets wrong, things Lexbor does that Parsec can’t, fixes, faster loops: all welcome. This page covers how the code is organised for contributors, how to build and test, and how a change gets in. The rules themselves are in CONTRIBUTING.md; this is the longer explanation.

Questions go to Discussions and bugs to Issues.

For anything bigger than a small fix, open an issue first so we can agree on the shape. Issues labelled good first issue are small and self-contained, and you’ll get help through them.

Every crate is written here: the HTML parser in crates/parsec, XPath in crates/parsec-xpath, and everything beside them. Make your change in this repository, as a pull request with its test, and that’s the whole route.

It used to be different. Until #208, the parser and XPath were developed in Netweir as crates/netweir-html and crates/netweir-xpath and copied here by a sync script, with a CI job that failed any edit made in Parsec alone. Older issues and pull requests that say “merged in Netweir and synced” come from then; the netweir-first label marks them. Now it runs the other way. Netweir dropped its copy in netweir#477 and takes Parsec’s released crates, so a parser fix lands here first and reaches Netweir through a Parsec release.

You need Rust 1.88 or newer, and nothing else.

Terminal window
git clone --recurse-submodules https://github.com/parsec-html/parsec
cd parsec
cargo test

If you cloned without --recurse-submodules, the tokenizer tests can’t find html5lib-tests:

Terminal window
git submodule update --init

Conformance explains the suites, what the counts mean, and the TREE_TEST and TREE_BRIEF variables for chasing a failing tree-construction case.

Run these before you push and you’ll save a round trip:

Terminal window
cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
cargo deny check

CI runs formatting and clippy with warnings as errors, cargo deny for licences, bans and sources (and separately for advisories, which shows red without blocking); that every Rust file starts with its licence header; and cargo test --workspace on Ubuntu, macOS and Windows. A CLA check and an OpenSSF Scorecard run as well.

The fuzz target, crates/parsec/fuzz/fuzz_targets/parse.rs, takes arbitrary bytes. The first byte picks scripting on or off and one of 13 fragment contexts (body, div, table, tr, select, template, textarea, script and html in HTML; svg and foreignObject in SVG; math and annotation-xml in MathML); the rest is decoded lossily as UTF-8 and parsed both as a document and as a fragment. After each parse it walks the tree and asserts that every node is reached once and that every child’s parent link points back.

It builds on nightly Rust with cargo-fuzz. From crates/parsec:

Terminal window
cargo install cargo-fuzz
cargo +nightly fuzz run parse

CI runs it every night for five minutes with inputs of up to 4,096 bytes. Locally, longer inputs find different things:

Terminal window
cargo +nightly fuzz run parse -- -max_len=65536 -max_total_time=3600

A crash goes in a private report, as SECURITY.md says, with the input that triggers it.

  • A bug fix comes with the test that would have caught it. A new feature comes with tests, and with an update to the docs page that documents it.
  • A new hostile input that’s slow goes into crates/parsec/examples/hostile.rs with the fix that makes it linear.
  • Commit subjects take a conventional prefix, describe the problem rather than the action, and stay within 72 characters: fix(tree): a table inside a template lost its foster parent. The body, wrapped at 72 columns, says what was wrong and what changed.
  • One change per pull request. The template asks what it fixes and how you tested it.

Parsec is Apache-2.0. Netweir, which is AGPL-3.0 and also sold under a commercial licence, is built on Parsec’s crates, so code that lands here goes there too. That only works if the maintainer can license each contribution under those terms as well, so before your first pull request is merged you’ll be asked to agree to the CLA. You keep the copyright in your work.

A check on your pull request asks you to post one comment, once:

I have read the CLA and I agree to it.

These pages are Parsec’s documentation, kept in parsec-html/website under apps/docs. Anyone with a GitHub account can suggest a fix to a page with the edit link at the bottom of it; for anything bigger, open an issue first. When the code changes, the page that documents it changes in the same piece of work.

Everyone taking part agrees to the Code of Conduct.

  • Architecture, for a tour of the code before you change it.
  • Conformance, for the test suites and how to chase a failing case.
  • Roadmap, for what’s planned and in what order.