diff --git a/AGENTS.md b/AGENTS.md
index a84a465..ff042bb 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -113,6 +113,8 @@ go/ Go module `github.com/4matic/trackparse/go`, package `
AllArtists, Parser/NewParser, ParseTracklist(With), ApplyEdits(With);
invalid UTF-8 is sanitized here (WHATWG maximal subparts to U+FFFD)
doc.go package overview shown on pkg.go.dev
+ LICENSE a copy of the root MIT license: the module zip holds only go/, and
+ pkg.go.dev hides the docs of a module without a license it can detect
types.go public structs and typed-string enums (mirror the schemas); nullable
fields are pointers
options.go ParseOptions, FormatOptions, Keywords, TracklistOptions (zero value = the
@@ -189,7 +191,7 @@ scripts/dump_py.py Python side of compare-ports (JSONL in, to_dict() JSON
.github/release-notes/ optional hand-written highlights prepended to a GitHub Release
release-please-config.json, .release-please-manifest.json release automation (never hand-edit the manifest)
js/CHANGELOG.md, spec/CHANGELOG.md, python/CHANGELOG.md, rust/CHANGELOG.md, go/CHANGELOG.md
- generated by release-please (go/CHANGELOG.md from the first Go release on)
+ generated by release-please
```
## Golden rule
@@ -478,6 +480,27 @@ matching site pages (`README.md`, `js/README.md`, `python/README.md`, `rust/READ
when a page or heading moves. Use full `https://4matic.github.io/trackparse/...` URLs: npm, PyPI,
crates.io and pkg.go.dev render the package READMEs where relative links break.
+**Link the first mention.** In each section of a README or a site page, link the first mention of
+a rule, option, field, warning or function to the place that explains it, and only the first:
+
+- a site page and heading anchor (`reference/functions/#formattrack-options`,
+ `guides/artists/#knownartists`); warnings use the text fragments described under
+ [Site internals](#site-internals-worth-knowing);
+- a spec rule on the generated spec page, `reference/spec/#r6-artisttitle-separator`. Only the
+ rule groups (`## R6 …`) and the R13 subsections (`#r132-times`, `#r1310-options`) have anchors;
+ a rule such as R6.10 links its group;
+- the API docs of that language: docs.rs item pages
+ (`https://docs.rs/trackparse/latest/trackparse/fn.parse_with.html`,
+ `…/tracklist/enum.Edit.html`, `…/struct.ParsedTrack.html#method.to_json`) and pkg.go.dev
+ anchors (`https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith`, `#Track.MarshalJSON`).
+ Check the anchor on the live page; pkg.go.dev ids are the identifier, `Type.Method` for methods.
+
+Give an example a prefilled playground link when seeing the whole output helps ("try it", "open
+this list in the playground"). The hash is `#track=` with optional `mode`, `splitAnd`,
+`known` and `uploader`, or `#list=` with optional `audioSeconds` and `known`; each value is
+`encodeURIComponent`-encoded, and in Markdown also encode `(`, `)` and `'` (`%28`, `%29`, `%27`)
+so the link target stays intact. Open the link once to check it shows what the text claims.
+
**Moving or removing a page.** npm (`homepage`), PyPI (`[project.urls]`) and published READMEs point
at site URLs that can't be changed after a release. When a page moves or disappears, add a
`redirects` entry in `site/astro.config.mjs` so the old URL keeps working, then update the
@@ -798,7 +821,7 @@ Version rules:
retries (`GOPROXY=https://proxy.golang.org go list -m github.com/4matic/trackparse/go@vX.Y.Z`),
runs `go get` and a small program from a clean module, requests the version's `.info` from the
proxy (pkg.go.dev adds versions it sees there; the page can take a few minutes), and appends
- install notes to the GitHub Release. **A published Go version is permanent**: the proxy and the
+ install notes to the GitHub Release. The 0.6.0 release was the first to run it, and it passed. **A published Go version is permanent**: the proxy and the
checksum database keep the tag's content forever, even if the tag is deleted or moved. Never
move or re-create a `go/v…` tag. A bad version can only be marked with a `retract` directive in
`go/go.mod`, released in a new version.
@@ -808,7 +831,7 @@ Version rules:
`-f rust_tag=rust-vX.Y.Z` (crates.io) or `-f go_tag=go/vX.Y.Z` (the Go checks, proxy request
and release notes; the module itself was published by the tag). The npm job always republishes from a fresh release; a
failed npm publish needs the same treatment by hand.
-- **Things the 0.5.0 release taught:**
+- **Things the 0.5.0 and 0.6.0 releases taught:**
- The release PR is opened with `GITHUB_TOKEN`, so no CI runs on it and GitHub shows it as
`UNSTABLE`. That is expected; `main` was green when it was generated.
- A `docs:` commit under `js/`, `python/`, `rust/` or `go/` (a package README) opens a release PR. A
@@ -819,8 +842,15 @@ Version rules:
- After a release, check every registry by API, not by badge: `registry.npmjs.org`,
`pypi.org/pypi/trackparse/json`, `crates.io/api/v1/crates/trackparse`, and the Go proxy:
`proxy.golang.org/github.com/4matic/trackparse/go/@v/list`.
- - The Go component's first changelog links `go/v0.5.1...go/vX.Y.Z`, a tag that never existed
- (the manifest starts Go at the linked 0.5.1), as rust's first entry linked `rust-v0.4.0`.
+ - The Go component's first changelog (0.6.0) links `go/v0.5.1...go/v0.6.0`, a tag that never
+ existed (the manifest started Go at the linked 0.5.1), as rust's first entry linked
+ `rust-v0.4.0`. Leave it: changelogs are not edited by hand, and the next entry links real tags.
+ - pkg.go.dev shows a module's documentation only when it detects a license file in the module
+ zip, and the zip of a module in `go/` holds only that folder: the root `LICENSE` is not in it.
+ `go/LICENSE` is a copy of it; keep the two the same. Since the zip of a published version
+ never changes, a missing license can only be fixed by a new version.
+ - Go has no registry badge with a version. The root README's "go module" badge reads the GitHub
+ tags (`github/v/tag/4matic/trackparse?filter=go%2Fv*`) and shows the whole tag, `go/v0.6.0`.
- Don't force-push a PR branch to pick up `main`: GitHub's rebase-merge rebases it when there
are no conflicts.
- **Agents never merge release PRs, publish, push tags or bump versions on their own initiative.**
diff --git a/README.md b/README.md
index 8bfead6..27b2717 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@
[](https://pypi.org/project/trackparse/)
[](https://crates.io/crates/trackparse)
[](https://docs.rs/trackparse)
+[](https://pkg.go.dev/github.com/4matic/trackparse/go?tab=versions)
[](https://pkg.go.dev/github.com/4matic/trackparse/go)
[](https://github.com/4matic/trackparse/actions/workflows/js.yml)
@@ -40,11 +41,15 @@ that Becky Hill is featured, that Sub Focus did the remix, or that it's a VIP.
trackparse keeps all of it. Its one rule is **extract, don't delete**: everything it recognizes
goes into a field, and anything it doesn't recognize stays in the title, word for word.
-It comes as an npm package, a PyPI package, a Rust crate and a Go module, all named `trackparse`.
-One [spec](spec/SPEC.md) and one set of fixtures define the behaviour. The four pass the same
-fixtures and give the same output on every fixture input. The example below is JavaScript;
-[Quick start](#quick-start) has the same calls in Python, Rust and Go, and you can try any string in
-the [playground](https://4matic.github.io/trackparse/playground/).
+It comes as an [npm package](https://www.npmjs.com/package/trackparse), a
+[PyPI package](https://pypi.org/project/trackparse/), a
+[Rust crate](https://crates.io/crates/trackparse) and a
+[Go module](https://pkg.go.dev/github.com/4matic/trackparse/go), all named `trackparse`.
+One [spec](spec/SPEC.md) and one set of [fixtures](spec/fixtures/README.md) define the behaviour.
+The four pass the same fixtures and give the same output on every fixture input. The example below
+is JavaScript; [Quick start](#quick-start) has the same calls in Python, Rust and Go. You can
+[try this string in the playground](https://4matic.github.io/trackparse/playground/#track=01.%20Wilkinson%20ft.%20Becky%20Hill%20%26%20Tom%20Cane%20-%20Afterglow%20%28Sub%20Focus%20VIP%20Remix%29%20%5BOfficial%20Video%5D),
+or any other.
```js
import { parse } from "trackparse";
@@ -98,8 +103,12 @@ track.position; // { raw: '01', number: 1 }
}
```
-Every key is always present. When a guess was involved, `warnings` says which one. Python's
-`to_dict()`, Rust's `to_json()` and Go's `MarshalJSON` give this same JSON.
+Every key is always present ([field reference](https://4matic.github.io/trackparse/reference/parse/#parsedtrack),
+[JSON Schema](spec/schema/parsed-track.schema.json)). When a guess was involved, `warnings` says
+which one. Python's [`to_dict()`](https://4matic.github.io/trackparse/reference/parse/#serializing-to-json),
+Rust's [`to_json()`](https://docs.rs/trackparse/latest/trackparse/struct.ParsedTrack.html#method.to_json)
+and Go's [`MarshalJSON`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track.MarshalJSON)
+give this same JSON.
@@ -109,17 +118,17 @@ Every key is always present. When a guess was involved, `warnings` says which on
| Number | What it means |
|---|---|
-| **13,130** shared fixtures | 1,203 written by hand, 11,927 generated from combinations. 100% pass in JS, Python, Rust and Go, nothing skipped. |
+| **13,130** shared fixtures | [1,203 written by hand](https://4matic.github.io/trackparse/project/testing/#handwritten-1203-cases), [11,927 generated](https://4matic.github.io/trackparse/project/testing/#generated-11927-cases) from combinations. 100% pass in JS, Python, Rust and Go, nothing skipped. |
| **1,239** of them on tracklists | 303 handwritten, 936 generated. They cover line splitting, times, bullets and Markdown, warnings and edits |
-| **1,352** JS tests | Every fixture, a schema check on every output, property-based tests of the spec invariants, API tests |
-| **27** version types | Remix, VIP, bootleg, extended, radio, original, live, remaster, sped up and more |
+| **1,352** JS tests | Every fixture, a schema check on every output, property-based tests of the [spec invariants](https://4matic.github.io/trackparse/reference/spec/#invariants), API tests |
+| **27** version types | [Remix, VIP, bootleg, extended, radio, original, live, remaster, sped up and more](https://4matic.github.io/trackparse/guides/versions/#the-27-types) |
| **0** dependencies in JS, Python and Go | The Rust crate has one, `unicode-normalization`. The JS package is ESM + CJS with TypeScript types, about 18 kB gzipped. `trackparse/tracklist` adds about 8.4 KiB, only if you import it |
| **Node 18+** | CI runs the full suite on 22 and 24, and every fixture against the built package on 18 and 20 |
| **Python 3.9+** | 1,342 pytest tests on 3.9 to 3.14, plus every fixture against the built wheel. Output is byte-identical to JS |
| **Rust 1.74+** | Every fixture, the tracklist invariants and the typed API tests on stable and on 1.74. Output is byte-identical to JS on every fixture and on about 790,000 random inputs |
| **Go 1.22+** | Every fixture, the spec invariants and the examples with `go test -race` on 1.22 and on the latest stable. Output is byte-identical to JS on every fixture and on about 790,000 random inputs |
-| **5,031** real tracklist lines | 117 podcast tracklists the tracklist rules were checked against. Every line round-trips byte for byte |
-| **1** spec | [`spec/SPEC.md`](spec/SPEC.md) defines the behaviour. The packages share its version and are released together; the Go module's first release is 0.6.0 |
+| **5,031** real tracklist lines | 117 podcast tracklists the tracklist rules were [checked against](https://4matic.github.io/trackparse/project/testing/#real-tracklists). Every line round-trips byte for byte |
+| **1** spec | [`spec/SPEC.md`](spec/SPEC.md) defines the behaviour ([on the site](https://4matic.github.io/trackparse/reference/spec/)). The four packages share its version number and are released together |
## Install
@@ -158,7 +167,10 @@ go get github.com/4matic/trackparse/go@latest
**Docs:** [Getting started](https://4matic.github.io/trackparse/start/getting-started/) · [Introduction](https://4matic.github.io/trackparse/start/introduction/)
-The four examples parse the same strings. The comments show what each expression evaluates to.
+The four examples parse the same strings with [`parse`](https://4matic.github.io/trackparse/reference/parse/),
+[`parseArtists`](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) and
+[`format`](https://4matic.github.io/trackparse/reference/functions/#formattrack-options). The comments show what each expression
+evaluates to.
### JavaScript
@@ -180,12 +192,12 @@ format(parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)"), { feat:
```
CommonJS works too: `const { parse } = require("trackparse")`. The full JavaScript API, with the
-TypeScript types, is in [`js/README.md`](js/README.md).
+TypeScript types, is in [`js/README.md`](js/README.md#api).
### Python
-Functions are snake_case and results are frozen dataclasses. `to_dict()` gives the spec's JSON
-with camelCase keys, the same as the JS package returns.
+Functions are snake_case and results are frozen dataclasses. [`to_dict()`](https://4matic.github.io/trackparse/reference/parse/#serializing-to-json)
+gives the spec's JSON with camelCase keys, the same as the JS package returns.
```python
from trackparse import format_track, parse, parse_artists
@@ -209,13 +221,15 @@ track.to_dict()["artists"][1]
# {'name': 'Foreign Beggars', 'role': 'featured', 'joiner': 'feat.', 'source': 'artist'}
```
-Options are keyword arguments: `parse(s, mode="youtube", known_artists=["Chase & Status"])`. The
-full Python API is in [`python/README.md`](python/README.md).
+Options are keyword arguments: `parse(s, mode="youtube", known_artists=["Chase & Status"])`
+([all options](https://4matic.github.io/trackparse/reference/options/)). The full Python API is in
+[`python/README.md`](python/README.md#api).
### Rust
-Results are structs with public fields, and roles, version types and junk kinds are enums.
-`to_json()` writes the spec's JSON, byte for byte what `JSON.stringify` gives in JS.
+Results are structs with public fields ([`ParsedTrack`](https://docs.rs/trackparse/latest/trackparse/struct.ParsedTrack.html)), and roles,
+version types and junk kinds are enums. [`to_json()`](https://docs.rs/trackparse/latest/trackparse/struct.ParsedTrack.html#method.to_json)
+writes the spec's JSON, byte for byte what `JSON.stringify` gives in JS.
```rust
use trackparse::{format_track_with, parse, parse_artists, FeatPlacement, FormatOptions, JoinerStyle};
@@ -241,16 +255,17 @@ track.artists[1].to_json();
// {"name":"Foreign Beggars","role":"featured","joiner":"feat.","source":"artist"}
```
-Options are builders passed to the `_with` form of a function:
-`parse_with(s, &ParseOptions::new().known_artists(["Chase & Status"]))`. The full Rust API is in
-[`rust/README.md`](rust/README.md) and on [docs.rs](https://docs.rs/trackparse).
+Options are builders ([`ParseOptions`](https://docs.rs/trackparse/latest/trackparse/struct.ParseOptions.html)) passed to the `_with` form
+of a function: `parse_with(s, &ParseOptions::new().known_artists(["Chase & Status"]))`. The full
+Rust API is in [`rust/README.md`](rust/README.md#api) and on [docs.rs](https://docs.rs/trackparse).
### Go
-Results are structs with exported fields; fields that can be `null` are pointers. Roles, version
-types and junk kinds are typed strings with constants (`trackparse.RoleFeatured`). `json.Marshal`
-gives the spec's JSON, with `&`, `<` and `>` escaped as `&`, `<` and `>`: the same
-values in different bytes. For the exact bytes of `JSON.stringify`, call `MarshalJSON` directly.
+Results are structs with exported fields ([`Track`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track)); fields that can be `null` are
+pointers. Roles, version types and junk kinds are typed strings with constants
+(`trackparse.RoleFeatured`). `json.Marshal` gives the spec's JSON, with `&`, `<` and `>` escaped as `&`, `<` and `>`: the same
+values in different bytes. For the exact bytes of `JSON.stringify`, call
+[`MarshalJSON`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track.MarshalJSON) directly.
```go
import (
@@ -289,11 +304,10 @@ fmt.Println(string(b))
// {"name":"Foreign Beggars","role":"featured","joiner":"feat.","source":"artist"}
```
-Options are plain structs whose zero value is the default (a field that must be told apart
-from its zero value is a pointer, set with `trackparse.Ptr`), passed to the `With` form of a
-function: `trackparse.ParseWith(s, trackparse.ParseOptions{KnownArtists: []string{"Chase & Status"}})`.
-The full Go API is in [`go/README.md`](go/README.md) and on
-[pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go).
+Options are plain structs whose zero value is the default ([`ParseOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseOptions); a
+field that must be told apart from its zero value is a pointer, set with
+[`trackparse.Ptr`](https://pkg.go.dev/github.com/4matic/trackparse/go#Ptr)), passed to the `With` form of a function: `trackparse.ParseWith(s, trackparse.ParseOptions{KnownArtists: []string{"Chase & Status"}})`.
+The full Go API is in [`go/README.md`](go/README.md#api) and on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go).
Every example on the [documentation site](https://4matic.github.io/trackparse/) has JavaScript,
Python, Rust and Go tabs.
@@ -311,39 +325,39 @@ Python, Rust and Go tabs.
**Docs:** [What it understands](https://4matic.github.io/trackparse/guides/what-it-understands/) · [Artists and credits](https://4matic.github.io/trackparse/guides/artists/) · [Versions and remixes](https://4matic.github.io/trackparse/guides/versions/) · [Junk, flags and prefixes](https://4matic.github.io/trackparse/guides/junk-and-flags/)
These are real outputs of `parse(input)` with default options, unless noted. They are the same in
-all four languages. To try your own strings, use the
-[playground](https://4matic.github.io/trackparse/playground/).
+all four languages. Each input opens in the [playground](https://4matic.github.io/trackparse/playground/) with that string filled
+in, so you can see the full output or change the string.
| Input | Artists | Title | Versions / other |
|---|---|---|---|
-| `Noisia feat. Foreign Beggars - Shellshock` | Noisia, Foreign Beggars *(feat)* | `Shellshock` | |
-| `Silk City - Electricity (with Dua Lipa)` | Silk City, Dua Lipa *(feat)* | `Electricity` | |
-| `Skrillex & Diplo x Justin Bieber - Where Are Ü Now` | Skrillex, Diplo, Justin Bieber | `Where Are Ü Now` | |
-| `Future - Mask Off (prod. by Metro Boomin)` | Future, Metro Boomin *(producer)* | `Mask Off` | |
-| `Linkin Park - Numb (Remix by Skrillex)` | Linkin Park | `Numb` | remix by Skrillex |
-| `Dimension - Offshore (Mefjus Remix / Noisia Remix)` | Dimension | `Offshore` | two remixes |
-| `Pendulum - Watercolour (Extended VIP Mix)` | Pendulum | `Watercolour` | vip, +extended |
-| `Noisia - Stigma (Phace Bootleg)` | Noisia | `Stigma` | bootleg by Phace |
-| `Deadmau5 - Strobe (Radio Edit)` | Deadmau5 | `Strobe` | radio |
-| `Netsky - Iron Heart (Levela Mix)` | Netsky | `Iron Heart` | remix by Levela |
-| `The Beatles - Hey Jude - Remastered 2015` | The Beatles | `Hey Jude` | remaster, 2015 |
-| `Taylor Swift - Love Story (Taylor's Version)` | Taylor Swift | `Love Story` | version, "Taylor's" |
-| `Kordhell - Murder In My Mind (Slowed + Reverb)` | Kordhell | `Murder In My Mind` | slowed |
-| `Eminem - Without Me (Explicit)` | Eminem | `Without Me` | explicit flag |
-| `Daft Punk - One More Time (Official Music Video) [HD]` | Daft Punk | `One More Time` | junk: video, quality |
-| `Elektronomia - Sky High [NCS Release]` | Elektronomia | `Sky High` | junk: label |
-| `Porter Robinson - Shelter - YouTube` | Porter Robinson | `Shelter` | junk: platform |
-| `01. Aphex Twin - Xtal` | Aphex Twin | `Xtal` | position 1 |
-| `[12:34] Noisia - Stigma` | Noisia | `Stigma` | timestamp 754 s |
-| `07_Burial_-_Archangel.mp3` | Burial | `Archangel` | filename mode, position 7 |
-| `"Numb" by Linkin Park` *(youtube)* | Linkin Park | `Numb` | warning `bySplit` |
-| `Blink-182-All The Small Things` *(youtube)* | Blink-182 | `All The Small Things` | warning `unspacedDashSplit` |
-| `Кино - Группа крови (Remastered 2019)` | Кино | `Группа крови` | remaster, 2019 |
-| `ID - ID (ID Remix)` | | `ID` | unknown artist, title and remixer |
-| `AC/DC - Back In Black` | AC/DC | `Back In Black` | |
-| `2 Unlimited - No Limit` | 2 Unlimited | `No Limit` | not a track number |
-| `Mumford & Sons - Little Lion Man` | Mumford & Sons | `Little Lion Man` | not split |
-| `The Rolling Stones - (I Can't Get No) Satisfaction` | The Rolling Stones | `(I Can't Get No) Satisfaction` | kept as is |
+| [`Noisia feat. Foreign Beggars - Shellshock`](https://4matic.github.io/trackparse/playground/#track=Noisia%20feat.%20Foreign%20Beggars%20-%20Shellshock) | Noisia, Foreign Beggars *(feat)* | `Shellshock` | |
+| [`Silk City - Electricity (with Dua Lipa)`](https://4matic.github.io/trackparse/playground/#track=Silk%20City%20-%20Electricity%20%28with%20Dua%20Lipa%29) | Silk City, Dua Lipa *(feat)* | `Electricity` | |
+| [`Skrillex & Diplo x Justin Bieber - Where Are Ü Now`](https://4matic.github.io/trackparse/playground/#track=Skrillex%20%26%20Diplo%20x%20Justin%20Bieber%20-%20Where%20Are%20%C3%9C%20Now) | Skrillex, Diplo, Justin Bieber | `Where Are Ü Now` | |
+| [`Future - Mask Off (prod. by Metro Boomin)`](https://4matic.github.io/trackparse/playground/#track=Future%20-%20Mask%20Off%20%28prod.%20by%20Metro%20Boomin%29) | Future, Metro Boomin *(producer)* | `Mask Off` | |
+| [`Linkin Park - Numb (Remix by Skrillex)`](https://4matic.github.io/trackparse/playground/#track=Linkin%20Park%20-%20Numb%20%28Remix%20by%20Skrillex%29) | Linkin Park | `Numb` | remix by Skrillex |
+| [`Dimension - Offshore (Mefjus Remix / Noisia Remix)`](https://4matic.github.io/trackparse/playground/#track=Dimension%20-%20Offshore%20%28Mefjus%20Remix%20%2F%20Noisia%20Remix%29) | Dimension | `Offshore` | two remixes |
+| [`Pendulum - Watercolour (Extended VIP Mix)`](https://4matic.github.io/trackparse/playground/#track=Pendulum%20-%20Watercolour%20%28Extended%20VIP%20Mix%29) | Pendulum | `Watercolour` | vip, +extended |
+| [`Noisia - Stigma (Phace Bootleg)`](https://4matic.github.io/trackparse/playground/#track=Noisia%20-%20Stigma%20%28Phace%20Bootleg%29) | Noisia | `Stigma` | bootleg by Phace |
+| [`Deadmau5 - Strobe (Radio Edit)`](https://4matic.github.io/trackparse/playground/#track=Deadmau5%20-%20Strobe%20%28Radio%20Edit%29) | Deadmau5 | `Strobe` | radio |
+| [`Netsky - Iron Heart (Levela Mix)`](https://4matic.github.io/trackparse/playground/#track=Netsky%20-%20Iron%20Heart%20%28Levela%20Mix%29) | Netsky | `Iron Heart` | remix by Levela |
+| [`The Beatles - Hey Jude - Remastered 2015`](https://4matic.github.io/trackparse/playground/#track=The%20Beatles%20-%20Hey%20Jude%20-%20Remastered%202015) | The Beatles | `Hey Jude` | remaster, 2015 |
+| [`Taylor Swift - Love Story (Taylor's Version)`](https://4matic.github.io/trackparse/playground/#track=Taylor%20Swift%20-%20Love%20Story%20%28Taylor%27s%20Version%29) | Taylor Swift | `Love Story` | version, "Taylor's" |
+| [`Kordhell - Murder In My Mind (Slowed + Reverb)`](https://4matic.github.io/trackparse/playground/#track=Kordhell%20-%20Murder%20In%20My%20Mind%20%28Slowed%20%2B%20Reverb%29) | Kordhell | `Murder In My Mind` | slowed |
+| [`Eminem - Without Me (Explicit)`](https://4matic.github.io/trackparse/playground/#track=Eminem%20-%20Without%20Me%20%28Explicit%29) | Eminem | `Without Me` | explicit flag |
+| [`Daft Punk - One More Time (Official Music Video) [HD]`](https://4matic.github.io/trackparse/playground/#track=Daft%20Punk%20-%20One%20More%20Time%20%28Official%20Music%20Video%29%20%5BHD%5D) | Daft Punk | `One More Time` | junk: video, quality |
+| [`Elektronomia - Sky High [NCS Release]`](https://4matic.github.io/trackparse/playground/#track=Elektronomia%20-%20Sky%20High%20%5BNCS%20Release%5D) | Elektronomia | `Sky High` | junk: label |
+| [`Porter Robinson - Shelter - YouTube`](https://4matic.github.io/trackparse/playground/#track=Porter%20Robinson%20-%20Shelter%20-%20YouTube) | Porter Robinson | `Shelter` | junk: platform |
+| [`01. Aphex Twin - Xtal`](https://4matic.github.io/trackparse/playground/#track=01.%20Aphex%20Twin%20-%20Xtal) | Aphex Twin | `Xtal` | position 1 |
+| [`[12:34] Noisia - Stigma`](https://4matic.github.io/trackparse/playground/#track=%5B12%3A34%5D%20Noisia%20-%20Stigma) | Noisia | `Stigma` | timestamp 754 s |
+| [`07_Burial_-_Archangel.mp3`](https://4matic.github.io/trackparse/playground/#track=07_Burial_-_Archangel.mp3) | Burial | `Archangel` | filename mode, position 7 |
+| [`"Numb" by Linkin Park`](https://4matic.github.io/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube) *(youtube)* | Linkin Park | `Numb` | warning `bySplit` |
+| [`Blink-182-All The Small Things`](https://4matic.github.io/trackparse/playground/#track=Blink-182-All%20The%20Small%20Things&mode=youtube) *(youtube)* | Blink-182 | `All The Small Things` | warning `unspacedDashSplit` |
+| [`Кино - Группа крови (Remastered 2019)`](https://4matic.github.io/trackparse/playground/#track=%D0%9A%D0%B8%D0%BD%D0%BE%20-%20%D0%93%D1%80%D1%83%D0%BF%D0%BF%D0%B0%20%D0%BA%D1%80%D0%BE%D0%B2%D0%B8%20%28Remastered%202019%29) | Кино | `Группа крови` | remaster, 2019 |
+| [`ID - ID (ID Remix)`](https://4matic.github.io/trackparse/playground/#track=ID%20-%20ID%20%28ID%20Remix%29) | | `ID` | unknown artist, title and remixer |
+| [`AC/DC - Back In Black`](https://4matic.github.io/trackparse/playground/#track=AC%2FDC%20-%20Back%20In%20Black) | AC/DC | `Back In Black` | |
+| [`2 Unlimited - No Limit`](https://4matic.github.io/trackparse/playground/#track=2%20Unlimited%20-%20No%20Limit) | 2 Unlimited | `No Limit` | not a track number |
+| [`Mumford & Sons - Little Lion Man`](https://4matic.github.io/trackparse/playground/#track=Mumford%20%26%20Sons%20-%20Little%20Lion%20Man) | Mumford & Sons | `Little Lion Man` | not split |
+| [`The Rolling Stones - (I Can't Get No) Satisfaction`](https://4matic.github.io/trackparse/playground/#track=The%20Rolling%20Stones%20-%20%28I%20Can%27t%20Get%20No%29%20Satisfaction) | The Rolling Stones | `(I Can't Get No) Satisfaction` | kept as is |
## Tracklists
@@ -351,13 +365,16 @@ all four languages. To try your own strings, use the
Mixes and podcasts come with a tracklist: a block of text, one track per line, usually with a start
time in front. The tracklist module reads the whole block: `trackparse/tracklist` in JavaScript,
-`trackparse.tracklist` in Python, `trackparse::tracklist` in Rust, and `ParseTracklist` in the
-main Go package. Each line gets its kind, its time
-and a full `ParsedTrack`. The list as a whole gets checks with line numbers, and edits rewrite only
-the lines you name.
+`trackparse.tracklist` in Python, [`trackparse::tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/index.html) in Rust, and
+[`ParseTracklist`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist) in the main Go package. Each line gets its
+[kind](https://4matic.github.io/trackparse/guides/tracklists/#line-kinds), its [time](https://4matic.github.io/trackparse/guides/tracklists/#times) and a full
+[`ParsedTrack`](https://4matic.github.io/trackparse/reference/parse/#parsedtrack). The list as a whole gets
+[checks with line numbers](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings), and [edits](https://4matic.github.io/trackparse/guides/editing-tracklists/)
+rewrite only the lines you name. The rules are [R13 in the spec](https://4matic.github.io/trackparse/reference/spec/#r13-tracklists).
Nothing is thrown away here either. Every line comes back with its original text and its own line
-ending, so joining `raw + eol` over the entries gives you the input byte for byte. CRLF, LF and CR
+ending, so joining `raw + eol` over the entries gives you the input byte for byte
+([R13.1](https://4matic.github.io/trackparse/reference/spec/#r131-lines-and-the-lossless-guarantee)). CRLF, LF and CR
all work, and trailing spaces survive.
```js
@@ -399,11 +416,12 @@ list.stats;
```
`00:11:02` sits between `01:07:44` and `01:15:36`. Changing one digit gives exactly one time that
-fits, `01:11:02`, so the warning carries it as a suggestion. When several fixes would fit, or none,
-`suggestion` is `null` and you only get the warning.
+fits, `01:11:02`, so the warning carries it as a [suggestion](https://4matic.github.io/trackparse/reference/warnings/#suggestions). When several
+fixes would fit, or none, `suggestion` is `null` and you only get the warning.
+[Open this list in the playground](https://4matic.github.io/trackparse/playground/#list=Hour%202%0A48%3A20%20Noisia%20-%20Stigma%0A52%3A47%20Mefjus%20%26%20Kasra%20-%20Bandwagon%20%28Phace%20Remix%29%0A56%3A05%20Black%20Sun%20Empire%20-%20ID%0A59%3A31%20Alix%20Perez%20-%20Fade%20Away%0A01%3A03%3A10%20Interview%20with%20Hybris%0A01%3A07%3A44%20Imanu%20-%20Sacrifice%0A00%3A11%3A02%20Current%20Value%20feat.%20Teddy%20Killerz%20-%20Payload%0A01%3A15%3A36%20Hybris%20-%20Spinning%20Top) to see every entry, or paste your own.
-Edits work on the text and return new text. Apply the suggestion, then push everything from line 5
-on back by 45 seconds:
+[Edits](https://4matic.github.io/trackparse/reference/tracklist/#edits) work on the text and return new text. Apply the
+suggestion, then push everything from line 5 on back by 45 seconds:
```js
const fix = list.warnings[1].suggestion;
@@ -427,7 +445,7 @@ result.text.split("\r\n").slice(4);
Lines 1 to 4 are untouched, CRLF included. A rewritten time keeps its line's style (hours or not,
digit widths, fraction digits), so `52:47` plus 45 seconds would stay `MM:SS`. `59:31` crossed the
hour, so it became `01:00:16` to match the list's other hour times, and the edit tells you with
-`style-upgraded`. A time pushed below zero stops at `00:00` and warns `time-clamped`. A bad edit
+`style-upgraded` ([edit warnings](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings)). A time pushed below zero stops at `00:00` and warns `time-clamped`. A bad edit
(missing line, line without a time, `NaN`) changes nothing and warns `edit-invalid`. Neither
function throws.
@@ -448,7 +466,7 @@ result.changed # (5, 6, 7, 8, 9)
result.warnings # (EditWarning(code='style-upgraded', edit=1, line=5),)
```
-In Rust an edit is an `Edit` value, and seconds are `f64`:
+In Rust an edit is an [`Edit`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.Edit.html) value, and seconds are `f64`:
```rust
use trackparse::tracklist::{apply_edits, parse_tracklist, Edit};
@@ -461,7 +479,7 @@ result.changed; // [5, 6, 7, 8, 9]
result.warnings; // [EditWarning { code: StyleUpgraded, edit: 1, line: Some(5) }]
```
-In Go an edit is an `Edit` value built by a constructor, and seconds are `float64`:
+In Go an edit is an [`Edit`](https://pkg.go.dev/github.com/4matic/trackparse/go#Edit) value built by a constructor, and seconds are `float64`:
```go
fmt.Println(*trackparse.ParseTracklist(text).Warnings[1].Suggestion)
@@ -491,24 +509,28 @@ text starts with `w/` is `layered`: a track played over the previous one
Inside a tracklist the first ` - ` is the artist/title separator on practically every line. A single
track string doesn't get that benefit of the doubt, so `parse()` sometimes reads the part after the
-dash as a version or a genre. `parseTracklist` parses each line with `mode: "tracklist"`, which
-trusts the first spaced dash. You can ask `parse()` for it too (`mode="tracklist"` in Python,
+dash as a version or a genre. `parseTracklist` parses each line with
+[`mode: "tracklist"`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode), which trusts the first spaced dash
+([R13.6](https://4matic.github.io/trackparse/reference/spec/#r136-tracklist-mode)). You can ask `parse()` for it too (`mode="tracklist"` in Python,
`ModeOption::Tracklist` in Rust, `ModeTracklist` in Go). These are real lines from a podcast archive:
| Line | `parse(line)` | In a tracklist |
|---|---|---|
-| `Electrosoul System - Liquid Metal` | title `Electrosoul System`, `Liquid Metal` as genre junk | Electrosoul System / `Liquid Metal` |
-| `Effector - 2012` | title `Effector`, year 2012 | Effector / `2012` |
-| `Paperclip - Anticipation VIP` | title `Paperclip`, a `vip` version | Paperclip / `Anticipation VIP` |
-| `ez4cheezy - Zhukovskiy dub` | title `ez4cheezy`, a `dub` version | ez4cheezy / `Zhukovskiy dub` |
+| [`Electrosoul System - Liquid Metal`](https://4matic.github.io/trackparse/playground/#track=Electrosoul%20System%20-%20Liquid%20Metal&mode=tracklist) | title `Electrosoul System`, `Liquid Metal` as genre junk | Electrosoul System / `Liquid Metal` |
+| [`Effector - 2012`](https://4matic.github.io/trackparse/playground/#track=Effector%20-%202012&mode=tracklist) | title `Effector`, year 2012 | Effector / `2012` |
+| [`Paperclip - Anticipation VIP`](https://4matic.github.io/trackparse/playground/#track=Paperclip%20-%20Anticipation%20VIP&mode=tracklist) | title `Paperclip`, a `vip` version | Paperclip / `Anticipation VIP` |
+| [`ez4cheezy - Zhukovskiy dub`](https://4matic.github.io/trackparse/playground/#track=ez4cheezy%20-%20Zhukovskiy%20dub&mode=tracklist) | title `ez4cheezy`, a `dub` version | ez4cheezy / `Zhukovskiy dub` |
| `8 Linkin Park_-_Points Of Authority (Gydra Bootleg)` | no separator | position 8, Linkin Park / `Points Of Authority`, bootleg by Gydra |
| `10 Optiv & BTK-Inception (Gydra remix)` | no separator | position 10, Optiv, BTK / `Inception`, remix by Gydra |
The last two rows need the neighbours. A bare `8 ` only counts as a position when the nearest line
-before or after it that has a time or a spaced dash starts with a bare 7 or 9. Dotted numbers like
-`01.` never count as neighbours, so `2 Unlimited - No Limit` between `01.` and `03.` stays an artist. The tight
+before or after it that has a time or a spaced dash starts with a bare 7 or 9
+([bare track numbers](https://4matic.github.io/trackparse/guides/tracklists/#bare-track-numbers),
+[R13.5](https://4matic.github.io/trackparse/reference/spec/#r135-bare-positions)). Dotted numbers like `01.` never count as
+neighbours, so `2 Unlimited - No Limit` between `01.` and `03.` stays an artist. The tight
`BTK-Inception` dash only splits on a timed line without a marker word, and only when at least half
-of the list uses spaced dashes.
+of the list uses spaced dashes ([R6.10](https://4matic.github.io/trackparse/reference/spec/#r6-artisttitle-separator)).
+[Try both lines with their neighbours](https://4matic.github.io/trackparse/playground/#list=00%3A00%207%20Noisia%20-%20Stigma%0A03%3A00%208%20Linkin%20Park_-_Points%20Of%20Authority%20%28Gydra%20Bootleg%29%0A06%3A00%209%20Optiv%20%26%20BTK-Inception%20%28Gydra%20remix%29%0A09%3A00%2010%20Imanu%20-%20Sacrifice) in the playground.
## How it's tested
@@ -520,16 +542,17 @@ fixtures pin it down, and every port has to pass all of them. The JS and Python
Rust crate and the Go module all do: **13,130 of 13,130**, with empty skip lists, in CI on every
push.
-Passing a fixture only checks the fields the case asserts, so
+Passing a fixture only checks the fields the case asserts ([matching rules](spec/fixtures/README.md#matching-semantics-match-partial)), so
[`scripts/compare-ports.mjs`](scripts/compare-ports.mjs) also runs every fixture input through all
four ports and diffs the complete outputs, tracklists and edits included. Result: 0 differences,
byte for byte. [`scripts/fuzz-ports.mjs`](scripts/fuzz-ports.mjs) does the same with random input.
The Rust crate and the Go module were each compared with JS on about 500,000 random single-track
-cases and 290,000 random tracklists with edits: 0 differences.
+cases and 290,000 random tracklists with edits: 0 differences
+([port against port](https://4matic.github.io/trackparse/project/testing/#port-against-port)).
### Handwritten: 1,203 cases in 27 files
-Each case cites the spec rules it exercises. 62 of them spell out the complete output field by
+Each case cites the [spec rules](https://4matic.github.io/trackparse/reference/spec/) it exercises. 62 of them spell out the complete output field by
field, so nothing can drift unnoticed.
| Group | Cases | What's in there |
@@ -573,7 +596,8 @@ line; the expected tracks are the plain lines' tracks.
### Properties
-Each port also checks the invariants from the spec on thousands of random strings. The JS suite
+Each port also checks the [invariants from the spec](https://4matic.github.io/trackparse/reference/spec/#invariants) on thousands
+of random strings. The JS suite
uses [fast-check](https://github.com/dubzzz/fast-check), the Python suite
[Hypothesis](https://hypothesis.works), and the Rust crate and the Go module small seeded
generators of their own, so they need no extra dev dependency. The Go module also has fuzz
@@ -588,7 +612,8 @@ targets for `go test -fuzz`. The invariants:
- no word of the input goes missing (the Rust and Go suites);
- `parse(format(parse(s)))` round-trips.
-For tracklists, on random multi-line text and random edit lists:
+For tracklists, on random multi-line text and random edit lists
+([R13.11](https://4matic.github.io/trackparse/reference/spec/#r1311-tracklist-invariants)):
- `raw + eol` over all entries gives the input back, and `lead + time + gap + rest` gives `raw`;
- `applyEdits(t, [])` returns `t`, and an edit never touches a line it doesn't name;
@@ -644,14 +669,18 @@ The four packages have the same functions:
| JavaScript | Python | Rust | Go |
|---|---|---|---|
-| `parse(input, options?)` | `parse(input, **options)` | `parse(input)`, `parse_with(input, &options)` | `Parse(input)`, `ParseWith(input, options)` |
-| `parseArtists(input, options?)` | `parse_artists(input, **options)` | `parse_artists(input)`, `parse_artists_with(input, &options)` | `ParseArtists(input)`, `ParseArtistsWith(input, options)` |
-| `format(track, options?)` | `format_track(track, **options)` | `format_track(&track)`, `format_track_with(&track, &options)` | `Format(track)`, `FormatWith(track, options)` |
-| `normalize(input)` | `normalize(input)` | `normalize(input)` | `Normalize(input)` |
-| `allArtists(track)` | `all_artists(track)` | `all_artists(&track)` | `AllArtists(track)` |
-| `createParser(options)` | `create_parser(**options)` | `Parser::new(&options)` | `NewParser(options)` |
-| `SPEC_VERSION` | `SPEC_VERSION` | `SPEC_VERSION` | `SpecVersion` |
-| `parseTracklist`, `applyEdits` from `trackparse/tracklist` | `parse_tracklist`, `apply_edits` from `trackparse.tracklist` | `parse_tracklist(_with)`, `apply_edits(_with)` from `trackparse::tracklist` | `ParseTracklist(With)`, `ApplyEdits(With)` in the same package |
+| [`parse(input, options?)`](https://4matic.github.io/trackparse/reference/parse/) | `parse(input, **options)` | [`parse(input)`](https://docs.rs/trackparse/latest/trackparse/fn.parse.html), [`parse_with(input, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_with.html) | [`Parse(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parse), [`ParseWith(input, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith) |
+| [`parseArtists(input, options?)`](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) | `parse_artists(input, **options)` | [`parse_artists(input)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists.html), [`parse_artists_with(input, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists_with.html) | [`ParseArtists(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtists), [`ParseArtistsWith(input, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtistsWith) |
+| [`format(track, options?)`](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) | `format_track(track, **options)` | [`format_track(&track)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track.html), [`format_track_with(&track, &options)`](https://docs.rs/trackparse/latest/trackparse/fn.format_track_with.html) | [`Format(track)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Format), [`FormatWith(track, options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatWith) |
+| [`normalize(input)`](https://4matic.github.io/trackparse/reference/functions/#normalizeinput) | `normalize(input)` | [`normalize(input)`](https://docs.rs/trackparse/latest/trackparse/fn.normalize.html) | [`Normalize(input)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Normalize) |
+| [`allArtists(track)`](https://4matic.github.io/trackparse/reference/functions/#allartiststrack) | `all_artists(track)` | [`all_artists(&track)`](https://docs.rs/trackparse/latest/trackparse/fn.all_artists.html) | [`AllArtists(track)`](https://pkg.go.dev/github.com/4matic/trackparse/go#AllArtists) |
+| [`createParser(options)`](https://4matic.github.io/trackparse/reference/functions/#createparseroptions) | `create_parser(**options)` | [`Parser::new(&options)`](https://docs.rs/trackparse/latest/trackparse/struct.Parser.html) | [`NewParser(options)`](https://pkg.go.dev/github.com/4matic/trackparse/go#NewParser) |
+| [`SPEC_VERSION`](https://4matic.github.io/trackparse/reference/functions/#spec_version) | `SPEC_VERSION` | [`SPEC_VERSION`](https://docs.rs/trackparse/latest/trackparse/constant.SPEC_VERSION.html) | [`SpecVersion`](https://pkg.go.dev/github.com/4matic/trackparse/go#SpecVersion) |
+| [`parseTracklist`](https://4matic.github.io/trackparse/reference/tracklist/#parsetracklisttext-options), [`applyEdits`](https://4matic.github.io/trackparse/reference/tracklist/#applyeditstext-edits-options) from `trackparse/tracklist` | `parse_tracklist`, `apply_edits` from `trackparse.tracklist` | [`parse_tracklist(_with)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.parse_tracklist.html), [`apply_edits(_with)`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.apply_edits.html) from [`trackparse::tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/index.html) | [`ParseTracklist(With)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist), [`ApplyEdits(With)`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEdits) in the same package |
+
+The JavaScript names link to the [API reference](https://4matic.github.io/trackparse/reference/parse/), which shows every
+language, Python included, in tabs. The Rust and Go names link to [docs.rs](https://docs.rs/trackparse)
+and [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go).
The tables below use the JavaScript names, which are also the keys of the JSON output. In Python
and Rust, options and fields are snake_case (`knownArtists` is `known_artists`, `fullTitle` is
@@ -661,34 +690,34 @@ structs with `Vec` and `Option`, the fixed sets of names are enums (`VersionType
exported CamelCase fields (`FullTitle`, `Version.Type`), pointers where the JSON has `null`, and
typed string constants for the fixed sets (`trackparse.VersionTypeRemix`). Each package README
lists its own signatures and types: [JavaScript](js/README.md#api), [Python](python/README.md#api),
-[Rust](rust/README.md#api), [Go](go/README.md#api). The Rust items are also on
-[docs.rs](https://docs.rs/trackparse), the Go ones on
-[pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go).
+[Rust](rust/README.md#api), [Go](go/README.md#api).
No function throws or panics on any string, and bad options fall back to the defaults. The one
exception is Python, which raises `TypeError` when the input is not a `str`.
### `parse(input, options?)` → `ParsedTrack`
+**Docs:** [ParsedTrack](https://4matic.github.io/trackparse/reference/parse/#parsedtrack) · [What it understands](https://4matic.github.io/trackparse/guides/what-it-understands/)
+
| Field | Type | |
|---|---|---|
| `input` | `string` | The original string, untouched |
-| `mode` | `"clean" \| "youtube" \| "filename" \| "tracklist"` | Resolved mode |
-| `position` | `{ raw, number } \| null` | Track number (`"01"` → 1) |
-| `timestamp` | `{ raw, seconds } \| null` | Leading cue time (`"1:02:03"` → 3723) |
-| `artists` | `Artist[]` | Primary, featured and producer credits. Remixers live in `versions` |
+| `mode` | `"clean" \| "youtube" \| "filename" \| "tracklist"` | Resolved [mode](https://4matic.github.io/trackparse/guides/modes/) |
+| `position` | `{ raw, number } \| null` | [Track number](https://4matic.github.io/trackparse/guides/junk-and-flags/#track-numbers) (`"01"` → 1) |
+| `timestamp` | `{ raw, seconds } \| null` | Leading [cue time](https://4matic.github.io/trackparse/guides/junk-and-flags/#cue-times) (`"1:02:03"` → 3723) |
+| `artists` | `Artist[]` | Primary, featured and producer [credits](https://4matic.github.io/trackparse/guides/artists/). Remixers live in `versions` |
| `title` | `string` | Clean title. Brackets it doesn't recognize stay in |
| `fullTitle` | `string` | `title` with versions re-attached |
-| `versions` | `Version[]` | Remixes and versions, left to right |
-| `year` | `number \| null` | From `(2015)` or `- 2015` |
-| `flags` | `{ explicit, clean, unknownArtist, unknownTitle }` | |
-| `junk` | `{ raw, kind }[]` | What was removed, and what kind of noise it was |
-| `warnings` | `string[]` | Heuristics that fired |
+| `versions` | `Version[]` | [Remixes and versions](https://4matic.github.io/trackparse/guides/versions/), left to right |
+| `year` | `number \| null` | [From](https://4matic.github.io/trackparse/guides/junk-and-flags/#year) `(2015)` or `- 2015` |
+| `flags` | `{ explicit, clean, unknownArtist, unknownTitle }` | [Flags](https://4matic.github.io/trackparse/guides/junk-and-flags/#flags) |
+| `junk` | `{ raw, kind }[]` | What was removed, and what [kind of noise](https://4matic.github.io/trackparse/guides/junk-and-flags/#junk) it was |
+| `warnings` | `string[]` | [Heuristics that fired](https://4matic.github.io/trackparse/reference/warnings/#track-warnings) |
Artist, Version, junk kinds and warnings
-**Artist:** `{ name, role, joiner, source }`
+**[Artist](https://4matic.github.io/trackparse/reference/parse/#artist):** `{ name, role, joiner, source }`
- `role` is `primary`, `featured`, `remixer` or `producer`. `&`, `x` and `vs.` are joiners, not roles.
- `joiner` is the text before the name as written (`"&"`, `","`, `"ft."`, `"prod. by"`), or `null`
@@ -696,18 +725,18 @@ exception is Python, which raises `TypeError` when the input is not a `str`.
- `source` is where the credit came from: `artist` (left of the dash), `title` (right of it) or
`version`.
-**Version:** `{ type, raw, artists, modifiers, descriptor, year, unknownArtist, delimiter }`
+**[Version](https://4matic.github.io/trackparse/reference/parse/#version):** `{ type, raw, artists, modifiers, descriptor, year, unknownArtist, delimiter }`
- `type`: `remix` `bootleg` `vip` `edit` `flip` `refix` `rework` `mashup` `blend` `dub` `mix`
`extended` `radio` `club` `original` `instrumental` `acapella` `live` `acoustic` `remaster` `demo`
`reprise` `cover` `version` `spedUp` `slowed` `nightcore`
-- A generic word takes its type from the word in front of it: `Radio Edit` → radio,
+- A [generic word](https://4matic.github.io/trackparse/guides/versions/#generic-words-borrow-their-meaning) takes its type from the word in front of it: `Radio Edit` → radio,
`Extended Mix` → extended. ` Mix` is a remix by that name.
- `modifiers` holds words that didn't become the type (`Extended VIP Mix` → vip, `["extended"]`).
`descriptor` holds leftover text (`"Taylor's"`, `"at Wembley"`, `"D'n'B"`).
- `delimiter` is `(`, `[`, `{`, or `-` for dash suffixes.
-**Junk kinds:** `video`, `audio`, `lyrics`, `quality`, `promo`, `platform`, `label`, `genre`, `other`.
+**[Junk kinds](https://4matic.github.io/trackparse/reference/parse/#junk-kinds):** `video`, `audio`, `lyrics`, `quality`, `promo`, `platform`, `label`, `genre`, `other`.
The vocabulary is in [`spec/data`](spec/data).
**Warnings:** `noSeparator`, `ambiguousSeparator`, `unspacedDashSplit`, `asymmetricDashSplit`,
@@ -724,17 +753,19 @@ The JSON shape is fixed by [`spec/schema/parsed-track.schema.json`](spec/schema/
| Option | Default | |
|---|---|---|
-| `mode` | `"auto"` | `"clean"`, `"youtube"`, `"filename"`, `"tracklist"`, or detect from the string |
-| `knownArtists` | `[]` | Names that are never split (`Chase & Status`, `Earth, Wind & Fire`) |
-| `uploader` | – | YouTube channel; in youtube mode it's used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
-| `splitAnd` | `"auto"` | `and` splits only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole |
-| `keywords` | – | Extra vocabulary: `versionHeads`, `descriptors`, `genres`, `junk`, `featMarkers` |
+| [`mode`](https://4matic.github.io/trackparse/guides/modes/) | `"auto"` | `"clean"`, `"youtube"`, `"filename"`, `"tracklist"`, or detect from the string |
+| [`knownArtists`](https://4matic.github.io/trackparse/guides/artists/#knownartists) | `[]` | Names that are never split (`Chase & Status`, `Earth, Wind & Fire`) |
+| [`uploader`](https://4matic.github.io/trackparse/guides/modes/#the-uploader-fallback) | – | YouTube channel; in youtube mode it's used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
+| [`splitAnd`](https://4matic.github.io/trackparse/guides/artists/#and-is-special) | `"auto"` | `and` splits only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole |
+| [`keywords`](https://4matic.github.io/trackparse/reference/options/#keywords) | – | Extra vocabulary: `versionHeads`, `descriptors`, `genres`, `junk`, `featMarkers` |
JavaScript takes an options object, Python takes keyword arguments
-(`parse(s, mode="youtube", uploader="Daft Punk")`), Rust takes a builder
+(`parse(s, mode="youtube", uploader="Daft Punk")`), Rust takes a builder,
+[`ParseOptions`](https://docs.rs/trackparse/latest/trackparse/struct.ParseOptions.html)
(`parse_with(s, &ParseOptions::new().mode(ModeOption::Youtube).uploader("Daft Punk"))`), and Go
-takes a struct whose zero value is the default
-(`ParseWith(s, ParseOptions{Mode: ModeYouTube, Uploader: "Daft Punk"})`).
+takes a struct whose zero value is the default, [`ParseOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseOptions)
+(`ParseWith(s, ParseOptions{Mode: ModeYouTube, Uploader: "Daft Punk"})`). The rules for options are
+[R12](https://4matic.github.io/trackparse/reference/spec/#r12-options) in the spec.
### Other functions
@@ -742,12 +773,12 @@ takes a struct whose zero value is the default
| Function | |
|---|---|
-| `parseArtists(input, options?)` | Split a bare artist string into credits |
-| `format(track, options?)` | Render back to a string. Options: `feat` (`source`/`artist`/`title`/`omit`), `featMarker`, `joiners` (`original`/`canonical`), `versions`, `producers`, `position` |
-| `normalize(input)` | The Unicode cleanup every function runs first: NFC, invisible characters, dash, bracket and quote variants |
-| `allArtists(track)` | Credits plus every remixer, deduplicated |
-| `createParser(options)` | Compile options once for repeated calls; per-call options merge over them |
-| `SPEC_VERSION` | The spec version this build implements |
+| [`parseArtists(input, options?)`](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) | Split a bare artist string into credits ([R10](https://4matic.github.io/trackparse/reference/spec/#r10-parseartists)) |
+| [`format(track, options?)`](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) | Render back to a string ([R11](https://4matic.github.io/trackparse/reference/spec/#r11-format)). [Options](https://4matic.github.io/trackparse/reference/options/#format-options): `feat` (`source`/`artist`/`title`/`omit`), `featMarker`, `joiners` (`original`/`canonical`), `versions`, `producers`, `position` |
+| [`normalize(input)`](https://4matic.github.io/trackparse/reference/functions/#normalizeinput) | The Unicode cleanup every function runs first: NFC, invisible characters, dash, bracket and quote variants ([R1](https://4matic.github.io/trackparse/reference/spec/#r1-normalization)) |
+| [`allArtists(track)`](https://4matic.github.io/trackparse/reference/functions/#allartiststrack) | Credits plus every remixer, deduplicated |
+| [`createParser(options)`](https://4matic.github.io/trackparse/reference/functions/#createparseroptions) | Compile options once for repeated calls; per-call options merge over them |
+| [`SPEC_VERSION`](https://4matic.github.io/trackparse/reference/functions/#spec_version) | The spec version this build implements |
```js
import { createParser } from "trackparse";
@@ -795,15 +826,15 @@ fmt.Println(parser.Parse("Chase & Status x Camo & Krooked - Track (Alix Perez Re
### Modes
-**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/)
+**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/) · [R2 in the spec](https://4matic.github.io/trackparse/reference/spec/#r2-mode-prelude)
| Mode | For | Adds |
|---|---|---|
| `clean` | Store metadata, tags | Only a spaced dash separates artist and title |
-| `youtube` | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
-| `filename` | Files | Strips the extension, `_` → space, `01-Track` numbering |
-| `auto` | Anything | `filename` for known extensions, `youtube` when it sees junk, pipes or platform suffixes, `clean` otherwise |
-| `tracklist` | One line of a tracklist | The first spaced dash always separates, and the words right after it are never read as a version or genre suffix. `_-_` splits too. `auto` never picks it |
+| [`youtube`](https://4matic.github.io/trackparse/guides/modes/#youtube-mode) | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
+| [`filename`](https://4matic.github.io/trackparse/guides/modes/#filename-mode) | Files | Strips the extension, `_` → space, `01-Track` numbering |
+| [`auto`](https://4matic.github.io/trackparse/guides/modes/#how-auto-decides) | Anything | `filename` for known extensions, `youtube` when it sees junk, pipes or platform suffixes, `clean` otherwise |
+| [`tracklist`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode) | One line of a tracklist | The first spaced dash always separates, and the words right after it are never read as a version or genre suffix. `_-_` splits too. `auto` never picks it |
### Tracklist API
@@ -816,18 +847,20 @@ JSON shape is fixed by [`spec/schema/tracklist.schema.json`](spec/schema/trackli
#### `parseTracklist(text, options?)` → `Tracklist`
-`{ specVersion, entries, warnings, stats }`, every key always present. One entry per line:
+`{ specVersion, entries, warnings, stats }`, every key always present
+([reference](https://4matic.github.io/trackparse/reference/tracklist/#parsetracklisttext-options), [R13.8](https://4matic.github.io/trackparse/reference/spec/#r138-output)). One
+[entry](https://4matic.github.io/trackparse/reference/tracklist/#tracklistentry) per line:
| Field | Type | |
|---|---|---|
| `line` | `number` | 1-based |
-| `kind` | `"track" \| "marker" \| "header" \| "link" \| "note" \| "blank"` | See below |
+| `kind` | `"track" \| "marker" \| "header" \| "link" \| "note" \| "blank"` | See below and [R13.3](https://4matic.github.io/trackparse/reference/spec/#r133-line-kinds) |
| `eol` | `"\n" \| "\r\n" \| "\r" \| ""` | The line's own terminator; `""` on a last line without one |
| `raw` | `string` | The line exactly as written, never normalized |
| `parts` | `{ lead, time, gap, rest }` | `raw` cut into four strings that join back into it. `lead` is spaces, a list bullet, Markdown emphasis or an opening bracket, `gap` is what sits between the time and the track (`] `, ` - `, ` \| `, ` => `) |
-| `time` | `{ raw, seconds } \| null` | `12:34`, `1:02:03`, `125:30` (long mixes), `00:00:07.500` (7.5 s) |
+| `time` | `{ raw, seconds } \| null` | [Time forms](https://4matic.github.io/trackparse/guides/tracklists/#times) ([R13.2](https://4matic.github.io/trackparse/reference/spec/#r132-times)): `12:34`, `1:02:03`, `125:30` (long mixes), `00:00:07.500` (7.5 s) |
| `track` | `ParsedTrack \| null` | Parsed from `rest` in tracklist mode, without Markdown emphasis, a leading `w/` and a bare track number. Only `track` and `marker` lines have one |
-| `layered` | `boolean` | The track text (after any time) starts with `w/` and a space: a track played over the previous one |
+| `layered` | `boolean` | The track text (after any time) starts with `w/` and a space: a track played over the previous one ([R13.13](https://4matic.github.io/trackparse/reference/spec/#r1313-layered-tracks)) |
Kinds: a line with a time is a `marker` when it has no separator and a word like `intro`, `break`
or `interview` ([`spec/data/marker-words.json`](spec/data/marker-words.json)), otherwise a
@@ -835,31 +868,33 @@ or `interview` ([`spec/data/marker-words.json`](spec/data/marker-words.json)), o
separator is a `track`, one with a marker word and no separator is a `marker`, and anything else is
a `note`. No line is ever dropped.
-`stats` is `{ lines, tracks, markers, timed, firstTime, lastTime }`.
+[`stats`](https://4matic.github.io/trackparse/reference/tracklist/#stats) is `{ lines, tracks, markers, timed, firstTime, lastTime }`.
-`warnings` are `{ code, line, severity, suggestion }`, sorted by line. Per-line `ParsedTrack`
+[`warnings`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings) are `{ code, line, severity, suggestion }`, sorted by line
+([R13.7](https://4matic.github.io/trackparse/reference/spec/#r137-warnings)). Per-line `ParsedTrack`
warnings stay on `entries[i].track.warnings` and are not repeated here.
| Code | Severity | When |
|---|---|---|
-| `time-missing` | warning | A track line has no time while other lines do (not raised on a `w/` line) |
-| `time-out-of-order` | warning | Earlier than the previous timed line. May carry a `suggestion` |
-| `time-duplicate` | warning | Same time as the previous timed line |
-| `no-start-at-zero` | info | The first time isn't `0:00` |
-| `time-after-audio-end` | warning | Past `audioSeconds` |
-| `invalid-time` | warning | Looks like a time but isn't one (`1:75`, `0:61:00`). The line keeps it in `rest` |
-| `position-gap` | warning | A track number isn't the previous one + 1 |
-| `position-duplicate` | warning | Same track number as the previous one |
-| `line-unparsed` | warning | A track line with no artist/title separator, or with nothing after the time |
-
-A `suggestion` is `{ line, raw, seconds }`: the one time, one or two digits away from the
+| [`time-missing`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dmissing) | warning | A track line has no time while other lines do (not raised on a `w/` line) |
+| [`time-out-of-order`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dout%2Dof%2Dorder) | warning | Earlier than the previous timed line. May carry a `suggestion` |
+| [`time-duplicate`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dduplicate) | warning | Same time as the previous timed line |
+| [`no-start-at-zero`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=no%2Dstart%2Dat%2Dzero) | info | The first time isn't `0:00` |
+| [`time-after-audio-end`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=time%2Dafter%2Daudio%2Dend) | warning | Past `audioSeconds` |
+| [`invalid-time`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=invalid%2Dtime) | warning | Looks like a time but isn't one (`1:75`, `0:61:00`). The line keeps it in `rest` |
+| [`position-gap`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=position%2Dgap) | warning | A track number isn't the previous one + 1 |
+| [`position-duplicate`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=position%2Dduplicate) | warning | Same track number as the previous one |
+| [`line-unparsed`](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings:~:text=line%2Dunparsed) | warning | A track line with no artist/title separator, or with nothing after the time |
+
+A [`suggestion`](https://4matic.github.io/trackparse/reference/warnings/#suggestions) is `{ line, raw, seconds }`: the one time, one or two digits away from the
original, that puts the line back in order. If no time fits, it tries the previous timed line
instead, since sometimes that is the typo (`01:22:21` followed by `01:03:55` suggests fixing the
first one to `01:02:21`). Several candidates or none give `null`.
#### `applyEdits(text, edits, options?)` → `{ text, changed, warnings }`
-Edits run in order, each on the result of the one before, with line numbers as that text has them.
+Edits run in order, each on the result of the one before, with line numbers as that text has them
+([reference](https://4matic.github.io/trackparse/reference/tracklist/#applyeditstext-edits-options), [R13.9](https://4matic.github.io/trackparse/reference/spec/#r139-edits)).
| Edit | Effect |
|---|---|
@@ -871,19 +906,19 @@ Edits run in order, each on the result of the one before, with line numbers as t
| `{ op: "delete", line }` | Remove a line |
`changed` lists the final line numbers of every line an edit wrote. Every other line keeps its
-bytes and its line ending. Edit warnings are `{ code, edit, line }`, where `edit` is the index in
+bytes and its line ending. [Edit warnings](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings) are `{ code, edit, line }`, where `edit` is the index in
`edits` and `line` is `null` when the edit names no line (an unknown `op`, say):
| Code | When |
|---|---|
-| `style-upgraded` | A time without hours passed one hour and gained them (`59:31` → `01:00:16`) |
-| `time-clamped` | A time would go below zero and was set to zero |
-| `edit-invalid` | Missing line, no time to set, a non-finite number, a time too large to write, a line break in `text`/`rest`, an unknown `op`. That edit changed nothing |
+| [`style-upgraded`](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings:~:text=style%2Dupgraded) | A time without hours passed one hour and gained them (`59:31` → `01:00:16`) |
+| [`time-clamped`](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings:~:text=time%2Dclamped) | A time would go below zero and was set to zero |
+| [`edit-invalid`](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings:~:text=edit%2Dinvalid) | Missing line, no time to set, a non-finite number, a time too large to write, a line break in `text`/`rest`, an unknown `op`. That edit changed nothing |
#### Tracklist options
-Both functions take the same options. `applyEdits` accepts them for symmetry; edits don't depend on
-them.
+Both functions take the same options ([R13.10](https://4matic.github.io/trackparse/reference/spec/#r1310-options)). `applyEdits` accepts them for
+symmetry; edits don't depend on them.
| Option | Default | |
|---|---|---|
@@ -895,19 +930,21 @@ them.
Python uses keyword arguments (`audio_seconds=`, `marker_words=`) and plain dicts for edits, with
the same keys as JS: `{"op": "shift", "seconds": 45, "from": 5}`.
-Rust has `parse_tracklist_with` and `apply_edits_with`, which take
+Rust has [`parse_tracklist_with`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.parse_tracklist_with.html) and
+[`apply_edits_with`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.apply_edits_with.html), which take
`&TracklistOptions::new().audio_seconds(3600.0).marker_words(["drop"])`. Edits are built with
-constructors on `Edit`: `set_time(line, seconds)`, `shift(seconds)`, `shift_from(seconds, from)`,
+constructors on [`Edit`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.Edit.html): `set_time(line, seconds)`, `shift(seconds)`, `shift_from(seconds, from)`,
`shift_lines(seconds, lines)`, `sort_by_time()`, `set_rest(line, rest)`, `insert(after, text)` and
`delete(line)`.
-Go has `ParseTracklistWith` and `ApplyEditsWith`, which take
+Go has [`ParseTracklistWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklistWith) and
+[`ApplyEditsWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEditsWith), which take a [`TracklistOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistOptions):
`TracklistOptions{AudioSeconds: trackparse.Ptr(3600.0), MarkerWords: []string{"drop"}}`. Edits
-are built with `SetTime(line, seconds)`, `Shift(seconds)`, `ShiftFrom(seconds, from)`,
+are built with [`SetTime(line, seconds)`](https://pkg.go.dev/github.com/4matic/trackparse/go#SetTime), `Shift(seconds)`, `ShiftFrom(seconds, from)`,
`ShiftLines(seconds, lines...)`, `SortByTime()`, `SetRest(line, rest)`, `Insert(after, text)` and
-`Delete(line)`. `AudioSeconds` is a pointer, so `nil` (unknown) and an audio of length 0 are
-different values, and `Mode: trackparse.ModeAuto` parses each line in auto mode
-([details](go/README.md#pointer-fields-and-ptr)).
+`Delete(line)`, which all return an [`Edit`](https://pkg.go.dev/github.com/4matic/trackparse/go#Edit). `AudioSeconds` is a pointer, so `nil`
+(unknown) and an audio of length 0 are different values, and `Mode: trackparse.ModeAuto` parses
+each line in auto mode ([details](go/README.md#pointer-fields-and-ptr)).
More on the options: [Tracklist options](https://4matic.github.io/trackparse/reference/options/#tracklist-options).
@@ -915,7 +952,8 @@ More on the options: [Tracklist options](https://4matic.github.io/trackparse/ref
**Docs:** [How it works](https://4matic.github.io/trackparse/project/how-it-works/)
-The parser is a fixed pipeline of hand-written scanners over code points. It uses no regexes with
+The parser is a fixed pipeline of hand-written scanners over code points
+([R0 portability](https://4matic.github.io/trackparse/reference/spec/#r0-portability)). It uses no regexes with
lookaround or backreferences and nothing backtracks, so long input can't make it hang: each port's
tests parse 10,000-code-point inputs under a time limit. Writing it this way is also what lets the
Python, Rust and Go ports give the same output as JavaScript.
@@ -932,13 +970,14 @@ flowchart LR
TI --> D
```
-Brackets are swapped for placeholders before anything is split, so a `&` inside `(Chase & Status
-Remix)` can't break the artist list. Groups are classified on their own: junk, feat, producer, flag,
-year, version, or unknown. Unknown ones go back into the title untouched. The full rules, R0–R12,
+Brackets are swapped for placeholders before anything is split ([R3](https://4matic.github.io/trackparse/reference/spec/#r3-group-scanner-and-skeleton)),
+so a `&` inside `(Chase & Status Remix)` can't break the artist list. Groups are classified on
+their own ([R5](https://4matic.github.io/trackparse/reference/spec/#r5-group-classification)): junk, feat, producer, flag, year, version, or
+unknown. Unknown ones go back into the title untouched. The full rules, R0–R12,
are in [spec/SPEC.md](spec/SPEC.md), which the site also shows as a
[page](https://4matic.github.io/trackparse/reference/spec/).
-Tracklists (R13) sit on top of that. The text is split into lines with their terminators, a small
+Tracklists ([R13](https://4matic.github.io/trackparse/reference/spec/#r13-tracklists)) sit on top of that. The text is split into lines with their terminators, a small
scanner reads the time at the start of each line, and the rest goes through the same pipeline in
tracklist mode. Two things look across lines: bare track numbers are only accepted when a neighbour
continues the sequence, and the unspaced-dash split is only switched on when most of the list uses
@@ -948,16 +987,17 @@ spaced dashes. The checks run last, over the finished entries.
**Docs:** [Ports](https://4matic.github.io/trackparse/project/ports/)
-| Language | Package | Needs | README | Changelog |
-|---|---|---|---|---|
-| JavaScript / TypeScript | [`trackparse`](https://www.npmjs.com/package/trackparse) on npm | Node 18+ or any ES2020 runtime, no dependencies | [js/README.md](js/README.md) | [js/CHANGELOG.md](js/CHANGELOG.md) |
-| Python | [`trackparse`](https://pypi.org/project/trackparse/) on PyPI | Python 3.9+, no dependencies | [python/README.md](python/README.md) | [python/CHANGELOG.md](python/CHANGELOG.md) |
-| Rust | [`trackparse`](https://crates.io/crates/trackparse) on crates.io ([docs.rs](https://docs.rs/trackparse)) | Rust 1.74+, `unicode-normalization`, optional `serde` feature | [rust/README.md](rust/README.md) | [rust/CHANGELOG.md](rust/CHANGELOG.md) |
-| Go | [`github.com/4matic/trackparse/go`](https://pkg.go.dev/github.com/4matic/trackparse/go) on pkg.go.dev | Go 1.22+, no dependencies | [go/README.md](go/README.md) | [go/CHANGELOG.md](go/CHANGELOG.md) |
+| Language | Package | Needs | API docs | README | Changelog |
+|---|---|---|---|---|---|
+| JavaScript / TypeScript | [`trackparse`](https://www.npmjs.com/package/trackparse) on npm | Node 18+ or any ES2020 runtime, no dependencies | [reference](https://4matic.github.io/trackparse/reference/parse/) | [js/README.md](js/README.md) | [js/CHANGELOG.md](js/CHANGELOG.md) |
+| Python | [`trackparse`](https://pypi.org/project/trackparse/) on PyPI | Python 3.9+, no dependencies | [reference](https://4matic.github.io/trackparse/reference/parse/) | [python/README.md](python/README.md) | [python/CHANGELOG.md](python/CHANGELOG.md) |
+| Rust | [`trackparse`](https://crates.io/crates/trackparse) on crates.io | Rust 1.74+, `unicode-normalization`, optional `serde` feature | [docs.rs](https://docs.rs/trackparse) | [rust/README.md](rust/README.md) | [rust/CHANGELOG.md](rust/CHANGELOG.md) |
+| Go | [`github.com/4matic/trackparse/go`](https://pkg.go.dev/github.com/4matic/trackparse/go) | Go 1.22+, no dependencies | [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) | [go/README.md](go/README.md) | [go/CHANGELOG.md](go/CHANGELOG.md) |
The JavaScript package is the reference implementation. All four pass 13,130 of 13,130 fixtures,
and the Python, Rust and Go output is byte-identical to JavaScript on every fixture input. Go
-releases are the tags `go/vX.Y.Z`, which the Go module proxy serves.
+releases are the tags `go/vX.Y.Z`, which the Go module proxy serves
+([versions](https://pkg.go.dev/github.com/4matic/trackparse/go?tab=versions)).
The spec and the packages share one version number and are released together, so the same
version means the same spec and the same fixtures in every language. The one known difference
diff --git a/go/README.md b/go/README.md
index e0cfe13..24414df 100644
--- a/go/README.md
+++ b/go/README.md
@@ -3,9 +3,9 @@
[](https://pkg.go.dev/github.com/4matic/trackparse/go)
[](https://github.com/4matic/trackparse/blob/main/go/go.mod)
[](https://github.com/4matic/trackparse/actions/workflows/go.yml)
-[](https://github.com/4matic/trackparse/blob/main/LICENSE)
+[](https://github.com/4matic/trackparse/blob/main/go/LICENSE)
-**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go)**
+**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go)** · **[Changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md)**
**Turn messy track names into structured data: who made it, who's featured, who remixed it, and
what's just noise.**
@@ -17,17 +17,18 @@ what's just noise.**
Most title parsers split that into `"Wilkinson ft. Becky Hill & Tom Cane"` and
`"Afterglow (Sub Focus VIP Remix)"` and stop. Others "clean" it and throw the feat and the remix
away. trackparse keeps all of it. Everything it recognizes goes into a field, and anything it
-doesn't recognize stays in the title, word for word.
+doesn't recognize stays in the title, word for word
+([try it in the playground](https://4matic.github.io/trackparse/playground/#track=01.%20Wilkinson%20ft.%20Becky%20Hill%20%26%20Tom%20Cane%20-%20Afterglow%20%28Sub%20Focus%20VIP%20Remix%29%20%5BOfficial%20Video%5D)).
This is the Go port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is defined
-by a [shared spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and pinned by
-13,130 fixtures. It passes all of them, and for every fixture input its output is byte-identical
+by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and pinned by
+[13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and for every fixture input its output is byte-identical
to the [JavaScript, Python and Rust packages](#other-languages).
- Go 1.22 or later (the `go` line of `go.mod`; CI runs the tests on 1.22 and on the latest stable)
- No dependencies: `go.mod` has no `require` line
- No `unsafe`, no cgo, no regular expressions
-- Never panics and never returns an error: any string gives a result
+- Never panics and never returns an error: any string gives a result ([Errors](#errors))
## Install
@@ -72,7 +73,8 @@ fmt.Println(trackparse.FormatWith(track, trackparse.FormatOptions{
// Wilkinson feat. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)
```
-`json.Marshal` gives the spec's JSON, with the same camelCase keys the JavaScript package uses:
+`json.Marshal` gives the spec's JSON, with the same camelCase keys the JavaScript package uses
+([JSON](#json) has the details):
```go
track := trackparse.Parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]")
@@ -146,19 +148,24 @@ ApplyEditsWith(text string, edits []Edit, options TracklistOptions) EditResult
```
Every function has a plain form with the default options and a `With` form that takes them.
-Tracklists are in the same package; there is no subpackage.
+Tracklists are in the same package; there is no subpackage. Each function has a section below, an
+entry on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go#pkg-index) and a page in the [API reference](https://4matic.github.io/trackparse/reference/functions/),
+where every example has a Go tab.
### `Parse` and `ParseOptions`
-**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/)
+**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/) · [`Parse`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parse), [`ParseWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseWith) and [`ParseOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseOptions) on pkg.go.dev
+
+Parses one track string, running [rules R1 to R9](https://4matic.github.io/trackparse/reference/spec/#r1-normalization) of the
+spec in order.
| Field | Zero value means | |
|---|---|---|
-| `Mode` | `ModeAuto` | `ModeClean`, `ModeYouTube`, `ModeFilename`, `ModeTracklist`, or `ModeAuto` to detect from the string. See [Modes](#modes) |
-| `Uploader` | none | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
-| `KnownArtists` | none | Names that are never split. There is no built-in list |
-| `SplitAnd` | `SplitAndAuto` | `SplitAndAuto` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `SplitAndAlways`, `SplitAndNever` |
-| `Keywords` | none | Extra vocabulary, added to the built-in lists (see below) |
+| [`Mode`](https://4matic.github.io/trackparse/guides/modes/) | `ModeAuto` | `ModeClean`, `ModeYouTube`, `ModeFilename`, `ModeTracklist`, or `ModeAuto` to detect from the string. See [Modes](#modes) |
+| [`Uploader`](https://4matic.github.io/trackparse/guides/modes/#the-uploader-fallback) | none | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
+| [`KnownArtists`](https://4matic.github.io/trackparse/guides/artists/#knownartists) | none | Names that are never split. There is no built-in list |
+| [`SplitAnd`](https://4matic.github.io/trackparse/guides/artists/#and-is-special) | `SplitAndAuto` | `SplitAndAuto` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `SplitAndAlways`, `SplitAndNever` |
+| [`Keywords`](https://4matic.github.io/trackparse/reference/options/#keywords) | none | Extra vocabulary, added to the built-in lists (see below) |
Options are plain structs, and the zero value of every struct is the default: `Parse(s)` is
`ParseWith(s, ParseOptions{})`. Set only the fields you need.
@@ -181,7 +188,8 @@ fmt.Println(names(trackparse.ParseWith("Simon and Garfunkel - Mrs. Robinson", tr
}))) // [Simon Garfunkel]
```
-`Keywords` adds words to the built-in lists:
+[`Keywords`](https://pkg.go.dev/github.com/4matic/trackparse/go#Keywords) adds words to the built-in lists
+([your own words](https://4matic.github.io/trackparse/guides/versions/#your-own-words)):
| Field | Type | |
|---|---|---|
@@ -216,7 +224,7 @@ a value someone may want to pass, the field is a pointer, and `nil` means "not s
- `TracklistOptions.AudioSeconds` is a `*float64`. `nil` means the length is unknown; a pointer to
`0` is an audio of length 0, which flags every time after `0:00`.
-`trackparse.Ptr(v)` returns a pointer to a copy of `v`, so a literal fits in one expression:
+[`trackparse.Ptr(v)`](https://pkg.go.dev/github.com/4matic/trackparse/go#Ptr) returns a pointer to a copy of `v`, so a literal fits in one expression:
`FormatOptions{FeatMarker: trackparse.Ptr("featuring")}`,
`TracklistOptions{AudioSeconds: trackparse.Ptr(3600.0)}`.
@@ -231,7 +239,7 @@ on. Nothing panics.
### `Track`
-**Docs:** [ParsedTrack fields](https://4matic.github.io/trackparse/reference/parse/#parsedtrack)
+**Docs:** [ParsedTrack fields](https://4matic.github.io/trackparse/reference/parse/#parsedtrack) · [`Track`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track) on pkg.go.dev
| Field | Type | |
|---|---|---|
@@ -272,8 +280,10 @@ fmt.Println(v.Type, *v.Descriptor, *v.Year) // live at Wembley 1986
```
Version types, junk kinds, warnings, roles, modes and the tracklist codes are typed strings
-(`type VersionType string`) with one constant per spec name: `VersionTypeRemix`,
-`JunkKindVideo`, `WarningNoSeparator`, `WarningCodeTimeOutOfOrder`. The value is the name used in
+(`type VersionType string`) with one constant per spec name: [`VersionTypeRemix`](https://pkg.go.dev/github.com/4matic/trackparse/go#VersionType),
+[`JunkKindVideo`](https://pkg.go.dev/github.com/4matic/trackparse/go#JunkKind), [`WarningNoSeparator`](https://pkg.go.dev/github.com/4matic/trackparse/go#Warning),
+[`WarningCodeTimeOutOfOrder`](https://pkg.go.dev/github.com/4matic/trackparse/go#WarningCode) ([the 27 version types](https://4matic.github.io/trackparse/guides/versions/#the-27-types),
+[junk kinds](https://4matic.github.io/trackparse/reference/parse/#junk-kinds)). The value is the name used in
the spec and in JSON, so `string(v.Type)` is `"remix"` and a `switch` on the constants works. A
function per type returns every constant in the spec's order, as a new slice each time
(`AllVersionTypes()`, `AllJunkKinds()`, `AllWarnings()`, ...):
@@ -292,13 +302,13 @@ its type or kind, and the result keeps that string as given.
**Docs:** [Serializing to JSON](https://4matic.github.io/trackparse/reference/parse/#serializing-to-json)
-Every result type has `MarshalJSON`, which writes compact JSON matching
+Every result type has [`MarshalJSON`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track.MarshalJSON), which writes compact JSON matching
[`parsed-track.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/parsed-track.schema.json)
and
[`tracklist.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/tracklist.schema.json):
camelCase keys in the schema's order, every key present, whole seconds as integers (`3167`, not
`3167.0`). Its bytes are those of `JSON.stringify(parse(s))` in JavaScript. `Track` also has
-`UnmarshalJSON`, which reads that form back; `Edit` marshals as the spec writes an edit
+[`UnmarshalJSON`](https://pkg.go.dev/github.com/4matic/trackparse/go#Track.UnmarshalJSON), which reads that form back; `Edit` marshals as the spec writes an edit
(`{"op":"set-time","line":3,"seconds":90}`).
`encoding/json` changes some bytes of what `MarshalJSON` returns, not the values:
@@ -328,7 +338,8 @@ methods.
**Docs:** [parseArtists](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) · [Artists and credits](https://4matic.github.io/trackparse/guides/artists/)
-Splits a bare artist string (no title). `ParseArtistsWith` takes the same options as `ParseWith`.
+Splits a bare artist string (no title) ([R10](https://4matic.github.io/trackparse/reference/spec/#r10-parseartists)).
+[`ParseArtistsWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseArtistsWith) takes the same options as `ParseWith`.
```go
for _, a := range trackparse.ParseArtists("Sub Focus, Wilkinson & Dimension feat. Kojo") {
@@ -344,7 +355,9 @@ for _, a := range trackparse.ParseArtists("Sub Focus, Wilkinson & Dimension feat
**Docs:** [format](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) · [Formatting](https://4matic.github.io/trackparse/guides/formatting/)
-Renders a track back to a string.
+Renders a track back to a string ([format options](https://4matic.github.io/trackparse/reference/options/#format-options),
+[R11](https://4matic.github.io/trackparse/reference/spec/#r11-format)): [`Format`](https://pkg.go.dev/github.com/4matic/trackparse/go#Format), [`FormatWith`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatWith),
+[`FormatOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#FormatOptions).
| Field | Zero value means | |
|---|---|---|
@@ -381,8 +394,8 @@ fmt.Println(trackparse.FormatWith(track, trackparse.FormatOptions{FeatMarker: tr
**Docs:** [normalize](https://4matic.github.io/trackparse/reference/functions/#normalizeinput)
The Unicode cleanup every function runs first: NFC, zero-width spaces, BOM and soft hyphens
-removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed.
-Running it twice changes nothing.
+removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed
+([R1](https://4matic.github.io/trackparse/reference/spec/#r1-normalization)). Running it twice changes nothing ([`Normalize`](https://pkg.go.dev/github.com/4matic/trackparse/go#Normalize)).
```go
fmt.Println(trackparse.Normalize("Noisia\u200b – Stigma (VIP)")) // Noisia - Stigma (VIP)
@@ -392,7 +405,8 @@ fmt.Println(trackparse.Normalize("Noisia\u200b – Stigma (VIP)")) // Noisia
**Docs:** [allArtists](https://4matic.github.io/trackparse/reference/functions/#allartiststrack)
-Credits plus every remixer, deduplicated.
+Credits plus every remixer, deduplicated ([R9](https://4matic.github.io/trackparse/reference/spec/#r9-assembly-and-dedup),
+[`AllArtists`](https://pkg.go.dev/github.com/4matic/trackparse/go#AllArtists)).
```go
track := trackparse.Parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus Remix)")
@@ -408,8 +422,8 @@ for _, a := range trackparse.AllArtists(track) {
**Docs:** [createParser](https://4matic.github.io/trackparse/reference/functions/#createparseroptions)
-Resolves the options and builds the word tables once, for many calls. `ParseWith` builds them on
-every call, so use a `Parser` when the options are the same each time.
+A [`Parser`](https://pkg.go.dev/github.com/4matic/trackparse/go#Parser) resolves the options and builds the word tables once, for many calls.
+`ParseWith` builds them on every call, so use a `Parser` when the options are the same each time.
```go
parser := trackparse.NewParser(trackparse.ParseOptions{
@@ -431,21 +445,23 @@ default tables are built once, on first use.
### `SpecVersion`
-The spec version this module implements. It equals the module version: the Go module, the npm
+**Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version) · [`SpecVersion`](https://pkg.go.dev/github.com/4matic/trackparse/go#SpecVersion) on pkg.go.dev
+
+The [spec](https://4matic.github.io/trackparse/reference/spec/) version this module implements. It equals the module version: the Go module, the npm
package, the PyPI package, the Rust crate and the spec are released together and always share one
version number.
## Modes
-**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/)
+**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/) · [R2 in the spec](https://4matic.github.io/trackparse/reference/spec/#r2-mode-prelude) · [`Mode`](https://pkg.go.dev/github.com/4matic/trackparse/go#Mode) on pkg.go.dev
| Mode | For | Adds |
|---|---|---|
| `ModeClean` | Store metadata, tags | Only a spaced dash separates artist and title |
-| `ModeYouTube` | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
-| `ModeFilename` | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
-| `ModeAuto` | Anything | `ModeFilename` for known extensions, `ModeYouTube` when it sees junk, pipes or platform suffixes, `ModeClean` otherwise |
-| `ModeTracklist` | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `ModeAuto` |
+| [`ModeYouTube`](https://4matic.github.io/trackparse/guides/modes/#youtube-mode) | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
+| [`ModeFilename`](https://4matic.github.io/trackparse/guides/modes/#filename-mode) | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
+| [`ModeAuto`](https://4matic.github.io/trackparse/guides/modes/#how-auto-decides) | Anything | `ModeFilename` for known extensions, `ModeYouTube` when it sees junk, pipes or platform suffixes, `ModeClean` otherwise |
+| [`ModeTracklist`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode) | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `ModeAuto` |
```go
youtube := trackparse.ParseOptions{Mode: trackparse.ModeYouTube}
@@ -459,23 +475,26 @@ youtube.Uploader = "Porter Robinson"
fmt.Println(trackparse.ParseWith("Shelter", youtube).Artists[0].Name) // Porter Robinson
```
+Try [`"Numb" by Linkin Park` in youtube mode](https://4matic.github.io/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube) or
+[`07_Burial_-_Archangel.mp3`](https://4matic.github.io/trackparse/playground/#track=07_Burial_-_Archangel.mp3) in the playground.
+
## Warnings
-**Docs:** [Warnings](https://4matic.github.io/trackparse/reference/warnings/)
+**Docs:** [Warnings](https://4matic.github.io/trackparse/reference/warnings/) · [`Warning`](https://pkg.go.dev/github.com/4matic/trackparse/go#Warning) on pkg.go.dev
The parser never fails, but it says when it had to guess. `track.Warnings` is a `[]Warning`,
empty when every decision was unambiguous.
| Constant | JSON name | Means |
|---|---|---|
-| `WarningNoSeparator` | `noSeparator` | No artist/title separator was found. The whole string is the title |
-| `WarningAmbiguousSeparator` | `ambiguousSeparator` | A two-part pipe title with no dash was read as artist and title |
-| `WarningUnspacedDashSplit` | `unspacedDashSplit` | Split at a dash without spaces around it |
-| `WarningAsymmetricDashSplit` | `asymmetricDashSplit` | Split at a dash with a space on one side only |
-| `WarningBySplit` | `bySplit` | Read `"Title" by Artist` |
-| `WarningQuotedTitleSplit` | `quotedTitleSplit` | Took a quoted span as the title and the text before it as the artist |
-| `WarningAmbiguousMixCredit` | `ambiguousMixCredit` | ` Mix` was read as a remix, but the name is long enough to be a style |
-| `WarningUnbalancedBrackets` | `unbalancedBrackets` | A bracket was opened and never closed |
+| `WarningNoSeparator` | [`noSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=noSeparator) | No artist/title separator was found. The whole string is the title |
+| `WarningAmbiguousSeparator` | [`ambiguousSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousSeparator) | A two-part pipe title with no dash was read as artist and title |
+| `WarningUnspacedDashSplit` | [`unspacedDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unspacedDashSplit) | Split at a dash without spaces around it |
+| `WarningAsymmetricDashSplit` | [`asymmetricDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=asymmetricDashSplit) | Split at a dash with a space on one side only |
+| `WarningBySplit` | [`bySplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=bySplit) | Read `"Title" by Artist` |
+| `WarningQuotedTitleSplit` | [`quotedTitleSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=quotedTitleSplit) | Took a quoted span as the title and the text before it as the artist |
+| `WarningAmbiguousMixCredit` | [`ambiguousMixCredit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousMixCredit) | ` Mix` was read as a remix, but the name is long enough to be a style |
+| `WarningUnbalancedBrackets` | [`unbalancedBrackets`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unbalancedBrackets) | A bracket was opened and never closed |
```go
track := trackparse.Parse("Around the World")
@@ -485,14 +504,14 @@ fmt.Println(track.Warnings[0] == trackparse.WarningNoSeparator) // true
fmt.Println(trackparse.Parse("Noisia - Stigma (VIP").Warnings) // [unbalancedBrackets]
```
-Tracklists have their own warnings, with line numbers. They are listed under
-[Tracklists](#tracklists).
+Tracklists have their own [warnings](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings), with line numbers. They are listed
+under [Tracklists](#tracklists).
## Tracklists
**Docs:** [Tracklists](https://4matic.github.io/trackparse/guides/tracklists/) · [Editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/) · [Tracklist API](https://4matic.github.io/trackparse/reference/tracklist/) · [Warnings](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings)
-`ParseTracklist` parses a whole tracklist, one entry per line, and checks it. Each entry keeps its
+[`ParseTracklist`](https://pkg.go.dev/github.com/4matic/trackparse/go#ParseTracklist) parses a whole tracklist, one entry per line, and checks it. Each entry keeps its
line exactly as written plus its own line ending, so joining every `Raw` and `Eol` is always the
input, CRLF or not.
@@ -540,10 +559,12 @@ s := list.Stats
fmt.Println(s.Lines, s.Tracks, s.Markers, s.Timed, *s.FirstTime, *s.LastTime) // 9 7 1 8 2900 4536
```
-The suggestion exists because exactly one time, one digit away from `00:11:02`, fits between its
-neighbours. With several candidates or none, `Suggestion` is `nil`.
+The [suggestion](https://4matic.github.io/trackparse/reference/warnings/#suggestions) exists because exactly one time, one digit away from `00:11:02`,
+fits between its neighbours. With several candidates or none, `Suggestion` is `nil`.
+[Open this list in the playground](https://4matic.github.io/trackparse/playground/#list=Hour%202%0A48%3A20%20Noisia%20-%20Stigma%0A52%3A47%20Mefjus%20%26%20Kasra%20-%20Bandwagon%20%28Phace%20Remix%29%0A56%3A05%20Black%20Sun%20Empire%20-%20ID%0A59%3A31%20Alix%20Perez%20-%20Fade%20Away%0A01%3A03%3A10%20Interview%20with%20Hybris%0A01%3A07%3A44%20Imanu%20-%20Sacrifice%0A00%3A11%3A02%20Current%20Value%20feat.%20Teddy%20Killerz%20-%20Payload%0A01%3A15%3A36%20Hybris%20-%20Spinning%20Top).
-`ApplyEdits` takes a slice of `Edit` values and only rewrites the lines they name:
+[`ApplyEdits`](https://pkg.go.dev/github.com/4matic/trackparse/go#ApplyEdits) takes a slice of [`Edit`](https://pkg.go.dev/github.com/4matic/trackparse/go#Edit) values and only rewrites the
+lines they name:
```go
text := "48:20 Noisia - Stigma\r\n59:31 Alix Perez - Fade Away\r\n00:03:10 Imanu - Sacrifice\r\n"
@@ -567,15 +588,16 @@ fmt.Println(result.Warnings[0].Code, result.Text == text) // edit-invalid true
A rewritten time keeps its line's style: `48:20` stays `MM:SS`, and a time that crosses the hour
gets hours, with a `style-upgraded` warning. A time pushed below zero stops at zero and warns
-`time-clamped`. A bad edit changes nothing and warns `edit-invalid`.
+`time-clamped`. A bad edit changes nothing and warns `edit-invalid`
+([edit warnings](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings), [editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/#times-keep-their-style)).
-Edits are built with `SetTime(line, seconds)`, `Shift(seconds)` (all timed lines),
+Edits ([reference](https://4matic.github.io/trackparse/reference/tracklist/#edits)) are built with [`SetTime(line, seconds)`](https://pkg.go.dev/github.com/4matic/trackparse/go#SetTime), `Shift(seconds)` (all timed lines),
`ShiftFrom(seconds, from)`, `ShiftLines(seconds, lines...)`, `SortByTime()`,
`SetRest(line, rest)`, `Insert(after, text)` (`after` 0 inserts at the top) and `Delete(line)`.
`Edit` is a plain struct with an `Op` field, so you can also fill it yourself; each operation reads
only its own fields. Line numbers are 1-based.
-`TracklistOptions` has `Mode` (zero value: `ModeTracklist`; `ModeAuto` picks a mode per line),
+[`TracklistOptions`](https://pkg.go.dev/github.com/4matic/trackparse/go#TracklistOptions) ([options](https://4matic.github.io/trackparse/reference/options/#tracklist-options)) has `Mode` (zero value: `ModeTracklist`; `ModeAuto` picks a mode per line),
`KnownArtists`, `SplitAnd`, `Keywords`, `AudioSeconds` (a `*float64`; it enables
`time-after-audio-end`) and `MarkerWords`:
@@ -607,17 +629,17 @@ previous one
([Markdown](https://4matic.github.io/trackparse/guides/tracklists/#markdown),
[layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)).
-Warning codes (`WarningCode`): `time-missing`, `time-out-of-order`, `time-duplicate`,
+[Warning codes](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings) ([`WarningCode`](https://pkg.go.dev/github.com/4matic/trackparse/go#WarningCode)): `time-missing`, `time-out-of-order`, `time-duplicate`,
`no-start-at-zero`, `time-after-audio-end` (needs `AudioSeconds`), `invalid-time`, `position-gap`,
`position-duplicate`, `line-unparsed`, as the constants `WarningCodeTimeMissing` to
`WarningCodeLineUnparsed`. Edit warnings (`EditWarningCode`): `EditWarningCodeEditInvalid`,
`EditWarningCodeTimeClamped`, `EditWarningCodeStyleUpgraded`. The
[Tracklist API reference](https://4matic.github.io/trackparse/reference/tracklist/) explains each
one, and the rules are in
-[SPEC R13](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md#r13-tracklists).
+[R13 of the spec](https://4matic.github.io/trackparse/reference/spec/#r13-tracklists).
-Every line is parsed with `ModeTracklist`, where the first spaced dash always separates artist and
-title. `ParseWith` accepts it too:
+Every line is parsed with [`ModeTracklist`](https://4matic.github.io/trackparse/guides/tracklists/#tracklist-mode), where the first
+spaced dash always separates artist and title. `ParseWith` accepts it too:
```go
track := trackparse.Parse("Electrosoul System - Liquid Metal")
@@ -631,7 +653,7 @@ fmt.Println(track.Title) // Liquid Metal
## Errors
-No function returns an `error` and none panics. `Parse` gives a complete `Track` for any string,
+No function returns an `error` and none panics ([R0.8](https://4matic.github.io/trackparse/reference/spec/#r0-portability)). `Parse` gives a complete `Track` for any string,
`""` included, and `ParseTracklist` and `ApplyEdits` return for any text. `ApplyEdits` reports an
edit it cannot apply (a line that does not exist, non-finite seconds) as an
`EditWarningCodeEditInvalid` warning and leaves the text alone. The only function with an `error`
@@ -667,8 +689,8 @@ fmt.Printf("%q\n", trackparse.Parse("Noisia - Sti\xffgma\xe2\x82").Title) // "St
- A `Parser` with options, the zero `Parser`, the package functions, `ParseTracklistWith` and
`ApplyEdits` are called from 16 goroutines at once and compared with a sequential run, under
the race detector in CI.
-- The `Example` functions in `example_test.go` are checked by `go test`, so the examples on
- pkg.go.dev run as shown.
+- The `Example` functions in [`example_test.go`](https://github.com/4matic/trackparse/blob/main/go/example_test.go) are checked by `go test`,
+ so the [examples on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go#pkg-examples) run as shown.
- [`scripts/compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs)
runs every fixture input through the JavaScript package and this module and compares the
complete JSON output, every field of it, not only the ones a fixture asserts. The Python and
@@ -689,7 +711,8 @@ Go toolchain that builds the program:
- `golang.org/x/text/unicode/norm` picks its NFC and NFD tables by build tag: Unicode 15 below
Go 1.27, Unicode 17 from Go 1.27.
-So the output does not depend on the Go version you build with.
+So the output does not depend on the Go version you build with. More in
+[what the Go port taught](https://4matic.github.io/trackparse/project/ports/#what-the-go-port-taught).
This differs from the Rust crate, which takes NFC and NFD from the `unicode-normalization` crate
and its Unicode 18 tables. Unicode 18 added 32 combining marks, so a string containing one of
@@ -716,9 +739,10 @@ Other programs were running, so the numbers vary by about 20% between runs:
**Changelog:** [go/CHANGELOG.md](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md)
-The module version is the spec version (`SpecVersion`). Releases are tagged `go/vX.Y.Z` in the
-repository, the tag form the Go toolchain expects for a module in a subfolder, and the Go
-module proxy serves them from there. There is no upload step: the tag is the release.
+The module version is the spec version ([`SpecVersion`](#specversion)). Releases are tagged
+`go/vX.Y.Z` in the repository, the tag form the Go toolchain expects for a module in a subfolder,
+and the Go module proxy serves them from there. There is no upload step: the tag is the release.
+Every published version is listed on [pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go?tab=versions).
While it is 0.x, a release that changes the output for some input bumps the minor version, and a
patch release only fixes bugs. `go get -u` moves to the newest minor, so if you store parsed
@@ -733,12 +757,12 @@ same fixtures, are released together under one version number, and return identi
every fixture input. You can parse in one language and read the result in another. The one known
difference is described under [Unicode version](#unicode-version).
-| Language | Package | Install |
-|---|---|---|
-| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` |
-| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` |
-| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` |
-| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` |
+| Language | Package | Install | Docs |
+|---|---|---|---|
+| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/js/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/js/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) |
+| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) |
## Limitations
@@ -789,4 +813,4 @@ spec, not here: see [AGENTS.md](https://github.com/4matic/trackparse/blob/main/A
## License
-[MIT](https://github.com/4matic/trackparse/blob/main/LICENSE)
+[MIT](https://github.com/4matic/trackparse/blob/main/go/LICENSE)
diff --git a/js/README.md b/js/README.md
index 5ec86e7..cbb1f2c 100644
--- a/js/README.md
+++ b/js/README.md
@@ -5,7 +5,7 @@
[](https://github.com/4matic/trackparse/actions/workflows/js.yml)
[](https://github.com/4matic/trackparse/blob/main/LICENSE)
-**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)**
+**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[API reference](https://4matic.github.io/trackparse/reference/parse/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[Changelog](https://github.com/4matic/trackparse/blob/main/js/CHANGELOG.md)**
**Turn messy track names into structured data: who made it, who's featured, who remixed it, and
what's just noise.**
@@ -17,18 +17,19 @@ what's just noise.**
Most title parsers split that into `"Wilkinson ft. Becky Hill & Tom Cane"` and
`"Afterglow (Sub Focus VIP Remix)"` and stop. Others "clean" it and throw the feat and the remix
away. trackparse keeps all of it. Everything it recognizes goes into a field, and anything it
-doesn't recognize stays in the title, word for word.
+doesn't recognize stays in the title, word for word
+([try it in the playground](https://4matic.github.io/trackparse/playground/#track=01.%20Wilkinson%20ft.%20Becky%20Hill%20%26%20Tom%20Cane%20-%20Afterglow%20%28Sub%20Focus%20VIP%20Remix%29%20%5BOfficial%20Video%5D)).
This is the JavaScript and TypeScript package of
[trackparse](https://github.com/4matic/trackparse), and the reference implementation. Its behaviour
-is defined by a [shared spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and
-pinned by 13,130 fixtures. It passes all of them, and the
+is defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and
+pinned by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and the
[Python, Rust and Go packages](#other-languages) return the same output for every one.
- Node 18 or later, browsers and other runtimes (no Node-specific APIs)
- No dependencies
- ESM and CommonJS, TypeScript types included
-- Never throws
+- [Never throws](#errors)
## Install
@@ -64,8 +65,9 @@ format(track, { joiners: "canonical" });
// 'Wilkinson feat. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)'
```
-The result is a plain object, so `JSON.stringify(track)` gives the spec's JSON form. Every key is
-always present:
+The result is a plain object, so `JSON.stringify(track)` gives the spec's JSON form
+([`ParsedTrack`](#parsedtrack), [serializing](https://4matic.github.io/trackparse/reference/parse/#serializing-to-json)). Every key
+is always present:
```js
console.log(JSON.stringify(track, null, 2));
@@ -128,19 +130,23 @@ parseTracklist(text: string, options?: TracklistOptions): Tracklist
applyEdits(text: string, edits: Edit[], options?: TracklistOptions): EditResult
```
+Each function has a section below and one in the [API reference](https://4matic.github.io/trackparse/reference/functions/).
+The tracklist functions are under [Tracklists](#tracklists).
+
### `parse(input, options?)`
**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/)
-Parses one track string.
+Parses one track string, running [rules R1 to R9](https://4matic.github.io/trackparse/reference/spec/#r1-normalization) of the
+spec in order.
| Option | Default | |
|---|---|---|
-| `mode` | `"auto"` | `"clean"`, `"youtube"`, `"filename"`, `"tracklist"`, or `"auto"` to detect from the string. See [Modes](#modes) |
-| `uploader` | – | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
-| `knownArtists` | `[]` | Names that are never split. There is no built-in list |
-| `splitAnd` | `"auto"` | `"auto"` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `"always"`, `"never"` |
-| `keywords` | – | Extra vocabulary, added to the built-in lists (see below) |
+| [`mode`](https://4matic.github.io/trackparse/guides/modes/) | `"auto"` | `"clean"`, `"youtube"`, `"filename"`, `"tracklist"`, or `"auto"` to detect from the string. See [Modes](#modes) |
+| [`uploader`](https://4matic.github.io/trackparse/guides/modes/#the-uploader-fallback) | – | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
+| [`knownArtists`](https://4matic.github.io/trackparse/guides/artists/#knownartists) | `[]` | Names that are never split. There is no built-in list |
+| [`splitAnd`](https://4matic.github.io/trackparse/guides/artists/#and-is-special) | `"auto"` | `"auto"` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `"always"`, `"never"` |
+| [`keywords`](https://4matic.github.io/trackparse/reference/options/#keywords) | – | Extra vocabulary, added to the built-in lists (see below) |
```js
parse("Chase & Status - Baddadan").artists.map((a) => a.name);
@@ -152,7 +158,7 @@ parse("Simon and Garfunkel - Mrs. Robinson", { splitAnd: "always" }).artists.map
// [ 'Simon', 'Garfunkel' ]
```
-`keywords` is an object with any of these keys:
+`keywords` is an object with any of these keys ([your own words](https://4matic.github.io/trackparse/guides/versions/#your-own-words)):
| Key | Type | |
|---|---|---|
@@ -218,10 +224,11 @@ parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)").versions[0];
// descriptor: 'at Wembley', year: 1986, unknownArtist: false, delimiter: '(' }
```
-- `VersionType`: `remix`, `bootleg`, `vip`, `edit`, `flip`, `refix`, `rework`, `mashup`, `blend`,
+- `VersionType` ([the 27 types](https://4matic.github.io/trackparse/guides/versions/#the-27-types)): `remix`, `bootleg`, `vip`, `edit`, `flip`, `refix`, `rework`, `mashup`, `blend`,
`dub`, `mix`, `extended`, `radio`, `club`, `original`, `instrumental`, `acapella`, `live`,
`acoustic`, `remaster`, `demo`, `reprise`, `cover`, `version`, `spedUp`, `slowed`, `nightcore`.
-- `JunkKind`: `video`, `audio`, `lyrics`, `quality`, `promo`, `platform`, `label`, `genre`, `other`.
+- `JunkKind` ([junk kinds](https://4matic.github.io/trackparse/reference/parse/#junk-kinds)): `video`, `audio`, `lyrics`, `quality`, `promo`,
+ `platform`, `label`, `genre`, `other`.
- `Warning`: see [Warnings](#warnings).
The same shape is published as a JSON Schema,
@@ -231,7 +238,7 @@ The same shape is published as a JSON Schema,
**Docs:** [parseArtists](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) · [Artists and credits](https://4matic.github.io/trackparse/guides/artists/)
-Splits a bare artist string (no title). Takes the same options as `parse`.
+Splits a bare artist string (no title) ([R10](https://4matic.github.io/trackparse/reference/spec/#r10-parseartists)). Takes the same options as `parse`.
```js
import { parseArtists } from "trackparse";
@@ -249,7 +256,8 @@ parseArtists("Sub Focus, Wilkinson & Dimension feat. Kojo");
**Docs:** [format](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) · [Formatting](https://4matic.github.io/trackparse/guides/formatting/)
-Renders a `ParsedTrack` back to a string: `Artists - Title (versions) (prod. ...)`.
+Renders a `ParsedTrack` back to a string: `Artists - Title (versions) (prod. ...)`
+([format options](https://4matic.github.io/trackparse/reference/options/#format-options), [R11](https://4matic.github.io/trackparse/reference/spec/#r11-format)).
| Option | Default | |
|---|---|---|
@@ -277,8 +285,8 @@ format(t, { position: true }); // '01. Wilkinson ft. Becky
**Docs:** [normalize](https://4matic.github.io/trackparse/reference/functions/#normalizeinput)
The Unicode cleanup every function runs first: NFC, zero-width spaces, BOM and soft hyphens
-removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed.
-Running it twice changes nothing.
+removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed
+([R1](https://4matic.github.io/trackparse/reference/spec/#r1-normalization)). Running it twice changes nothing.
```js
import { normalize } from "trackparse";
@@ -291,7 +299,7 @@ normalize(" Artist\u200b — Title (Remix) “Quoted” ");
**Docs:** [allArtists](https://4matic.github.io/trackparse/reference/functions/#allartiststrack)
-Credits plus every remixer, deduplicated.
+Credits plus every remixer, deduplicated ([R9](https://4matic.github.io/trackparse/reference/spec/#r9-assembly-and-dedup)).
```js
import { allArtists, parse } from "trackparse";
@@ -326,21 +334,23 @@ r.junk; // [ { raw: 'Full Album', kind: 'other' } ]
### `SPEC_VERSION`
-The version of the spec this build implements. It equals the package version: the npm package,
+**Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version)
+
+The version of the [spec](https://4matic.github.io/trackparse/reference/spec/) this build implements. It equals the package version: the npm package,
the PyPI package, the Rust crate, the Go module and the spec are released together and always
share one version number.
## Modes
-**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/)
+**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/) · [R2 in the spec](https://4matic.github.io/trackparse/reference/spec/#r2-mode-prelude)
| Mode | For | Adds |
|---|---|---|
| `clean` | Store metadata, tags | Only a spaced dash separates artist and title |
-| `youtube` | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
-| `filename` | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
-| `auto` | Anything | `filename` for known extensions, `youtube` when it sees junk, pipes or platform suffixes, `clean` otherwise |
-| `tracklist` | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `auto` |
+| [`youtube`](https://4matic.github.io/trackparse/guides/modes/#youtube-mode) | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
+| [`filename`](https://4matic.github.io/trackparse/guides/modes/#filename-mode) | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
+| [`auto`](https://4matic.github.io/trackparse/guides/modes/#how-auto-decides) | Anything | `filename` for known extensions, `youtube` when it sees junk, pipes or platform suffixes, `clean` otherwise |
+| [`tracklist`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode) | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `auto` |
```js
let t = parse('"Numb" by Linkin Park', { mode: "youtube" });
@@ -358,6 +368,9 @@ parse("Jay-Z-Numb").title; // 'Jay-Z-N
parse("Jay-Z-Numb", { mode: "youtube" }).artists.map((a) => a.name); // [ 'Jay-Z' ]
```
+Try [`"Numb" by Linkin Park` in youtube mode](https://4matic.github.io/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube) or
+[`07_Burial_-_Archangel.mp3`](https://4matic.github.io/trackparse/playground/#track=07_Burial_-_Archangel.mp3) in the playground.
+
## Warnings
**Docs:** [Warnings](https://4matic.github.io/trackparse/reference/warnings/)
@@ -367,14 +380,14 @@ empty when every decision was unambiguous.
| Warning | Means |
|---|---|
-| `noSeparator` | No artist/title separator was found. The whole string is the title |
-| `ambiguousSeparator` | A two-part pipe title with no dash was read as artist and title |
-| `unspacedDashSplit` | Split at a dash without spaces around it |
-| `asymmetricDashSplit` | Split at a dash with a space on one side only |
-| `bySplit` | Read `"Title" by Artist` |
-| `quotedTitleSplit` | Took a quoted span as the title and the text before it as the artist |
-| `ambiguousMixCredit` | ` Mix` was read as a remix, but the name is long enough to be a style |
-| `unbalancedBrackets` | A bracket was opened and never closed |
+| [`noSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=noSeparator) | No artist/title separator was found. The whole string is the title |
+| [`ambiguousSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousSeparator) | A two-part pipe title with no dash was read as artist and title |
+| [`unspacedDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unspacedDashSplit) | Split at a dash without spaces around it |
+| [`asymmetricDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=asymmetricDashSplit) | Split at a dash with a space on one side only |
+| [`bySplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=bySplit) | Read `"Title" by Artist` |
+| [`quotedTitleSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=quotedTitleSplit) | Took a quoted span as the title and the text before it as the artist |
+| [`ambiguousMixCredit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousMixCredit) | ` Mix` was read as a remix, but the name is long enough to be a style |
+| [`unbalancedBrackets`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unbalancedBrackets) | A bracket was opened and never closed |
```js
const t = parse("Around the World");
@@ -385,8 +398,8 @@ parse("Noisia - Stigma (VIP").warnings;
// [ 'unbalancedBrackets' ]
```
-Tracklists have their own warnings, with line numbers. They are listed under
-[Tracklists](#tracklists).
+Tracklists have their own [warnings](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings), with line numbers. They are listed
+under [Tracklists](#tracklists).
## Tracklists
@@ -437,10 +450,11 @@ list.stats;
// { lines: 9, tracks: 7, markers: 1, timed: 8, firstTime: 2900, lastTime: 4536 }
```
-The suggestion exists because exactly one time, one digit away from `00:11:02`, fits between its
-neighbours. With several candidates or none, `suggestion` is `null`.
+The [suggestion](https://4matic.github.io/trackparse/reference/warnings/#suggestions) exists because exactly one time, one digit away from `00:11:02`,
+fits between its neighbours. With several candidates or none, `suggestion` is `null`.
+[Open this list in the playground](https://4matic.github.io/trackparse/playground/#list=Hour%202%0A48%3A20%20Noisia%20-%20Stigma%0A52%3A47%20Mefjus%20%26%20Kasra%20-%20Bandwagon%20%28Phace%20Remix%29%0A56%3A05%20Black%20Sun%20Empire%20-%20ID%0A59%3A31%20Alix%20Perez%20-%20Fade%20Away%0A01%3A03%3A10%20Interview%20with%20Hybris%0A01%3A07%3A44%20Imanu%20-%20Sacrifice%0A00%3A11%3A02%20Current%20Value%20feat.%20Teddy%20Killerz%20-%20Payload%0A01%3A15%3A36%20Hybris%20-%20Spinning%20Top).
-`applyEdits` takes an array of edit objects and only rewrites the lines they name:
+`applyEdits` takes an array of [edit objects](https://4matic.github.io/trackparse/reference/tracklist/#edits) and only rewrites the lines they name:
```js
const fix = list.warnings[1].suggestion;
@@ -459,10 +473,11 @@ applyEdits(text, [{ op: "shift", seconds: -3000, lines: [2, 3] }]).warnings;
A rewritten time keeps its line's style: `52:47` stays `MM:SS`, and a time that crosses the hour
gets hours like the rest of the list, with a `style-upgraded` warning. A time pushed below zero
-stops at zero and warns `time-clamped`. A bad edit changes nothing and warns `edit-invalid`.
+stops at zero and warns `time-clamped`. A bad edit changes nothing and warns `edit-invalid`
+([edit warnings](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings), [editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/#times-keep-their-style)).
-Both functions take the options `mode` (default `"tracklist"`), `knownArtists`, `splitAnd` and
-`keywords`, as `parse` does, plus `audioSeconds` (the length of the audio, which turns on the
+Both functions take the [options](https://4matic.github.io/trackparse/reference/options/#tracklist-options) `mode` (default
+`"tracklist"`), `knownArtists`, `splitAnd` and `keywords`, as `parse` does, plus `audioSeconds` (the length of the audio, which turns on the
`time-after-audio-end` check) and `markerWords` (extra words that make a line a marker):
```js
@@ -489,19 +504,19 @@ previous one
([Markdown](https://4matic.github.io/trackparse/guides/tracklists/#markdown),
[layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)).
-Warning codes: `time-missing`, `time-out-of-order`, `time-duplicate`, `no-start-at-zero`,
+[Warning codes](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings): `time-missing`, `time-out-of-order`, `time-duplicate`, `no-start-at-zero`,
`time-after-audio-end` (needs `audioSeconds`), `invalid-time`, `position-gap`,
`position-duplicate`, `line-unparsed`. Edits: `set-time {line, seconds}`,
`shift {seconds, lines? | from?}` (all timed lines when neither is given), `sort-by-time {}`,
`set-rest {line, rest}`, `insert {after, text}` (`after: 0` inserts at the top), `delete {line}`.
The [Tracklist API reference](https://4matic.github.io/trackparse/reference/tracklist/) explains
each one, and the rules are in
-[SPEC R13](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md#r13-tracklists).
+[R13 of the spec](https://4matic.github.io/trackparse/reference/spec/#r13-tracklists).
`JSON.stringify(list)` matches
[`tracklist.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/tracklist.schema.json).
-Every line is parsed with `mode: "tracklist"`, where the first spaced dash always separates artist
-and title. `parse()` accepts it too:
+Every line is parsed with [`mode: "tracklist"`](https://4matic.github.io/trackparse/guides/tracklists/#tracklist-mode), where the
+first spaced dash always separates artist and title. `parse()` accepts it too:
```js
parse("Electrosoul System - Liquid Metal").junk;
@@ -512,7 +527,7 @@ parse("Electrosoul System - Liquid Metal", { mode: "tracklist" }).title;
## Errors
-No function throws. `parse` returns a complete `ParsedTrack` for any string, `""` included, and a
+No function throws ([R0.8](https://4matic.github.io/trackparse/reference/spec/#r0-portability)). `parse` returns a complete `ParsedTrack` for any string, `""` included, and a
value that isn't a string is read as `""`. An option of the wrong type or with an unknown value is
ignored and the default is used. `applyEdits` reports a bad edit as an `edit-invalid` warning and
leaves the text alone.
@@ -559,7 +574,8 @@ catches a misspelt name.
**Changelog:** [js/CHANGELOG.md](https://github.com/4matic/trackparse/blob/main/js/CHANGELOG.md)
-The package version is the spec version (`SPEC_VERSION`). While it is 0.x, a release that changes
+The package version is the spec version ([`SPEC_VERSION`](#spec_version)); every release is on
+[npm](https://www.npmjs.com/package/trackparse?activeTab=versions). While it is 0.x, a release that changes
the output for some input bumps the minor version, and a patch release only fixes bugs. If you
store parsed results, pin the minor version with a tilde range (`"trackparse": "~0.6.0"` stays on
0.6.x) and read the changelog before moving up.
@@ -572,12 +588,12 @@ The same parser exists for Python, Rust and Go. All four implement one spec, pas
fixtures, are released together under one version number, and return identical JSON for every
fixture input. You can parse in one language and read the result in another.
-| Language | Package | Install |
-|---|---|---|
-| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` |
-| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` |
-| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` |
-| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` |
+| Language | Package | Install | Docs |
+|---|---|---|---|
+| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/js/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/js/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) |
+| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) |
## Limitations
diff --git a/python/README.md b/python/README.md
index e8ee640..956a73b 100644
--- a/python/README.md
+++ b/python/README.md
@@ -5,7 +5,7 @@
[](https://github.com/4matic/trackparse/actions/workflows/python.yml)
[](https://github.com/4matic/trackparse/blob/main/LICENSE)
-**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)**
+**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[API reference](https://4matic.github.io/trackparse/reference/parse/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[Changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md)**
**Turn messy track names into structured data: who made it, who's featured, who remixed it, and
what's just noise.**
@@ -17,17 +17,18 @@ what's just noise.**
Most title parsers split that into `"Wilkinson ft. Becky Hill & Tom Cane"` and
`"Afterglow (Sub Focus VIP Remix)"` and stop. Others "clean" it and throw the feat and the remix
away. trackparse keeps all of it. Everything it recognizes goes into a field, and anything it
-doesn't recognize stays in the title, word for word.
+doesn't recognize stays in the title, word for word
+([try it in the playground](https://4matic.github.io/trackparse/playground/#track=01.%20Wilkinson%20ft.%20Becky%20Hill%20%26%20Tom%20Cane%20-%20Afterglow%20%28Sub%20Focus%20VIP%20Remix%29%20%5BOfficial%20Video%5D)).
This is the Python port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is
-defined by a [shared spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and pinned
-by 13,130 fixtures. It passes all of them, and for every fixture input its output is byte-identical
+defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and pinned
+by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and for every fixture input its output is byte-identical
to the [JavaScript, Rust and Go packages](#other-languages).
- Python 3.9 to 3.14
- No dependencies
-- Typed (`py.typed`), immutable results
-- Never raises on `str` input
+- [Typed](#typing) (`py.typed`), immutable results
+- [Never raises](#errors) on `str` input
## Install
@@ -63,7 +64,8 @@ format_track(track, joiners="canonical")
# 'Wilkinson feat. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix)'
```
-`to_dict()` returns the spec's JSON form, with the same camelCase keys the JS package uses:
+[`to_dict()`](#to_dict-and-from_dict) returns the spec's JSON form, with the same camelCase keys the JS
+package uses:
```python
import json
@@ -130,17 +132,23 @@ parse_tracklist(text, *, mode="tracklist", known_artists=(), keywords=None, spli
apply_edits(text, edits, *, ) -> EditResult
```
+Each function has a section below and one in the [API reference](https://4matic.github.io/trackparse/reference/functions/),
+where every example has a Python tab. The tracklist functions are under [Tracklists](#tracklists).
+
### `parse(input, **options)`
**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/)
+Parses one track string, running [rules R1 to R9](https://4matic.github.io/trackparse/reference/spec/#r1-normalization) of the
+spec in order.
+
| Option | Default | |
|---|---|---|
-| `mode` | `"auto"` | `"clean"`, `"youtube"`, `"filename"`, `"tracklist"`, or `"auto"` to detect from the string. See [Modes](#modes) |
-| `uploader` | `None` | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
-| `known_artists` | `()` | Names that are never split. There is no built-in list |
-| `split_and` | `"auto"` | `"auto"` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `"always"`, `"never"` |
-| `keywords` | `None` | Extra vocabulary, added to the built-in lists (see below) |
+| [`mode`](https://4matic.github.io/trackparse/guides/modes/) | `"auto"` | `"clean"`, `"youtube"`, `"filename"`, `"tracklist"`, or `"auto"` to detect from the string. See [Modes](#modes) |
+| [`uploader`](https://4matic.github.io/trackparse/guides/modes/#the-uploader-fallback) | `None` | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
+| [`known_artists`](https://4matic.github.io/trackparse/guides/artists/#knownartists) | `()` | Names that are never split. There is no built-in list |
+| [`split_and`](https://4matic.github.io/trackparse/guides/artists/#and-is-special) | `"auto"` | `"auto"` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `"always"`, `"never"` |
+| [`keywords`](https://4matic.github.io/trackparse/reference/options/#keywords) | `None` | Extra vocabulary, added to the built-in lists (see below) |
```python
[a.name for a in parse("Chase & Status - Baddadan").artists]
@@ -152,7 +160,7 @@ apply_edits(text, edits, *, ) -> EditResult
# ['Simon', 'Garfunkel']
```
-`keywords` is a dict with any of these keys:
+`keywords` is a dict with any of these keys ([your own words](https://4matic.github.io/trackparse/guides/versions/#your-own-words)):
| Key | Type | |
|---|---|---|
@@ -208,10 +216,11 @@ parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)").versions[0]
# descriptor='at Wembley', year=1986, unknown_artist=False, delimiter='(')
```
-- `VersionType`: `remix`, `bootleg`, `vip`, `edit`, `flip`, `refix`, `rework`, `mashup`, `blend`,
+- `VersionType` ([the 27 types](https://4matic.github.io/trackparse/guides/versions/#the-27-types)): `remix`, `bootleg`, `vip`, `edit`, `flip`, `refix`, `rework`, `mashup`, `blend`,
`dub`, `mix`, `extended`, `radio`, `club`, `original`, `instrumental`, `acapella`, `live`,
`acoustic`, `remaster`, `demo`, `reprise`, `cover`, `version`, `spedUp`, `slowed`, `nightcore`.
-- `JunkKind`: `video`, `audio`, `lyrics`, `quality`, `promo`, `platform`, `label`, `genre`, `other`.
+- `JunkKind` ([junk kinds](https://4matic.github.io/trackparse/reference/parse/#junk-kinds)): `video`, `audio`, `lyrics`, `quality`, `promo`,
+ `platform`, `label`, `genre`, `other`.
- `Warning`: see [Warnings](#warnings).
These are plain strings, typed as `Literal` aliases (see [Typing](#typing)).
@@ -236,7 +245,7 @@ ParsedTrack.from_dict(track.to_dict()) == track # True
**Docs:** [parseArtists](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) · [Artists and credits](https://4matic.github.io/trackparse/guides/artists/)
-Splits a bare artist string (no title). Takes the same options as `parse`.
+Splits a bare artist string (no title) ([R10](https://4matic.github.io/trackparse/reference/spec/#r10-parseartists)). Takes the same options as `parse`.
```python
from trackparse import parse_artists
@@ -249,7 +258,8 @@ from trackparse import parse_artists
**Docs:** [format](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) · [Formatting](https://4matic.github.io/trackparse/guides/formatting/)
-Renders a track back to a string.
+Renders a track back to a string ([format options](https://4matic.github.io/trackparse/reference/options/#format-options),
+[R11](https://4matic.github.io/trackparse/reference/spec/#r11-format)).
| Option | Default | |
|---|---|---|
@@ -279,8 +289,8 @@ format_track(t, position=True) # '01. Wilkinson ft. Becky Hill - Afterglow (Sub
**Docs:** [normalize](https://4matic.github.io/trackparse/reference/functions/#normalizeinput)
The Unicode cleanup every function runs first: NFC, zero-width spaces, BOM and soft hyphens
-removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed.
-Running it twice changes nothing.
+removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed
+([R1](https://4matic.github.io/trackparse/reference/spec/#r1-normalization)). Running it twice changes nothing.
```python
from trackparse import normalize
@@ -293,7 +303,7 @@ normalize("Noisia\u200b – Stigma (VIP)")
**Docs:** [allArtists](https://4matic.github.io/trackparse/reference/functions/#allartiststrack)
-Credits plus every remixer, deduplicated.
+Credits plus every remixer, deduplicated ([R9](https://4matic.github.io/trackparse/reference/spec/#r9-assembly-and-dedup)).
```python
from trackparse import all_artists
@@ -323,21 +333,23 @@ parser.parse("Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)").versi
### `SPEC_VERSION`
-The version of the spec this build implements. It equals `__version__`: the PyPI package, the npm
+**Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version)
+
+The version of the [spec](https://4matic.github.io/trackparse/reference/spec/) this build implements. It equals `__version__`: the PyPI package, the npm
package, the Rust crate, the Go module and the spec are released together and always share one
version number.
## Modes
-**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/)
+**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/) · [R2 in the spec](https://4matic.github.io/trackparse/reference/spec/#r2-mode-prelude)
| Mode | For | Adds |
|---|---|---|
| `clean` | Store metadata, tags | Only a spaced dash separates artist and title |
-| `youtube` | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
-| `filename` | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
-| `auto` | Anything | `filename` for known extensions, `youtube` when it sees junk, pipes or platform suffixes, `clean` otherwise |
-| `tracklist` | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `auto` |
+| [`youtube`](https://4matic.github.io/trackparse/guides/modes/#youtube-mode) | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
+| [`filename`](https://4matic.github.io/trackparse/guides/modes/#filename-mode) | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
+| [`auto`](https://4matic.github.io/trackparse/guides/modes/#how-auto-decides) | Anything | `filename` for known extensions, `youtube` when it sees junk, pipes or platform suffixes, `clean` otherwise |
+| [`tracklist`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode) | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `auto` |
```python
t = parse('"Numb" by Linkin Park', mode="youtube")
@@ -352,6 +364,9 @@ parse("Shelter", mode="youtube", uploader="Porter Robinson").artists
# (Artist(name='Porter Robinson', role='primary', joiner=None, source='artist'),)
```
+Try [`"Numb" by Linkin Park` in youtube mode](https://4matic.github.io/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube) or
+[`07_Burial_-_Archangel.mp3`](https://4matic.github.io/trackparse/playground/#track=07_Burial_-_Archangel.mp3) in the playground.
+
## Warnings
**Docs:** [Warnings](https://4matic.github.io/trackparse/reference/warnings/)
@@ -361,14 +376,14 @@ empty when every decision was unambiguous.
| Warning | Means |
|---|---|
-| `noSeparator` | No artist/title separator was found. The whole string is the title |
-| `ambiguousSeparator` | A two-part pipe title with no dash was read as artist and title |
-| `unspacedDashSplit` | Split at a dash without spaces around it |
-| `asymmetricDashSplit` | Split at a dash with a space on one side only |
-| `bySplit` | Read `"Title" by Artist` |
-| `quotedTitleSplit` | Took a quoted span as the title and the text before it as the artist |
-| `ambiguousMixCredit` | ` Mix` was read as a remix, but the name is long enough to be a style |
-| `unbalancedBrackets` | A bracket was opened and never closed |
+| [`noSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=noSeparator) | No artist/title separator was found. The whole string is the title |
+| [`ambiguousSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousSeparator) | A two-part pipe title with no dash was read as artist and title |
+| [`unspacedDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unspacedDashSplit) | Split at a dash without spaces around it |
+| [`asymmetricDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=asymmetricDashSplit) | Split at a dash with a space on one side only |
+| [`bySplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=bySplit) | Read `"Title" by Artist` |
+| [`quotedTitleSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=quotedTitleSplit) | Took a quoted span as the title and the text before it as the artist |
+| [`ambiguousMixCredit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousMixCredit) | ` Mix` was read as a remix, but the name is long enough to be a style |
+| [`unbalancedBrackets`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unbalancedBrackets) | A bracket was opened and never closed |
```python
t = parse("Around the World")
@@ -379,8 +394,8 @@ parse("Noisia - Stigma (VIP").warnings
# ('unbalancedBrackets',)
```
-Tracklists have their own warnings, with line numbers. They are listed under
-[Tracklists](#tracklists).
+Tracklists have their own [warnings](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings), with line numbers. They are listed
+under [Tracklists](#tracklists).
## Tracklists
@@ -428,10 +443,11 @@ tl.stats
# Stats(lines=9, tracks=7, markers=1, timed=8, first_time=2900, last_time=4536)
```
-The suggestion exists because exactly one time, one digit away from `00:11:02`, fits between its
-neighbours. With several candidates or none, `suggestion` is `None`.
+The [suggestion](https://4matic.github.io/trackparse/reference/warnings/#suggestions) exists because exactly one time, one digit away from `00:11:02`,
+fits between its neighbours. With several candidates or none, `suggestion` is `None`.
+[Open this list in the playground](https://4matic.github.io/trackparse/playground/#list=Hour%202%0A48%3A20%20Noisia%20-%20Stigma%0A52%3A47%20Mefjus%20%26%20Kasra%20-%20Bandwagon%20%28Phace%20Remix%29%0A56%3A05%20Black%20Sun%20Empire%20-%20ID%0A59%3A31%20Alix%20Perez%20-%20Fade%20Away%0A01%3A03%3A10%20Interview%20with%20Hybris%0A01%3A07%3A44%20Imanu%20-%20Sacrifice%0A00%3A11%3A02%20Current%20Value%20feat.%20Teddy%20Killerz%20-%20Payload%0A01%3A15%3A36%20Hybris%20-%20Spinning%20Top).
-`apply_edits` takes a list of dicts with the spec's keys (`op`, `line`, `seconds`, `lines`, `from`,
+`apply_edits` takes a list of dicts with the [spec's keys](https://4matic.github.io/trackparse/reference/tracklist/#edits) (`op`, `line`, `seconds`, `lines`, `from`,
`after`, `text`, `rest`) and only rewrites the lines they name:
```python
@@ -454,9 +470,10 @@ apply_edits(text, [{"op": "shift", "seconds": -3000, "lines": [2, 3]}]).warnings
A rewritten time keeps its line's style: `52:47` stays `MM:SS`, and a time that crosses the hour
gets hours like the rest of the list, with a `style-upgraded` warning. A time pushed below zero
-stops at zero and warns `time-clamped`. A bad edit changes nothing and warns `edit-invalid`.
+stops at zero and warns `time-clamped`. A bad edit changes nothing and warns `edit-invalid`
+([edit warnings](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings), [editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/#times-keep-their-style)).
-Both functions take the keyword options `mode` (default `"tracklist"`), `known_artists`,
+Both functions take the keyword [options](https://4matic.github.io/trackparse/reference/options/#tracklist-options) `mode` (default `"tracklist"`), `known_artists`,
`split_and` and `keywords`, as `parse` does, plus `audio_seconds` (the length of the audio, which
turns on the `time-after-audio-end` check) and `marker_words` (extra words that make a line a
marker):
@@ -486,20 +503,20 @@ previous one
([Markdown](https://4matic.github.io/trackparse/guides/tracklists/#markdown),
[layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)).
-Warning codes: `time-missing`, `time-out-of-order`, `time-duplicate`, `no-start-at-zero`,
+[Warning codes](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings): `time-missing`, `time-out-of-order`, `time-duplicate`, `no-start-at-zero`,
`time-after-audio-end` (needs `audio_seconds`), `invalid-time`, `position-gap`,
`position-duplicate`, `line-unparsed`. Edits: `set-time {line, seconds}`, `shift {seconds, lines? | from?}`
(all timed lines when neither is given), `sort-by-time {}`, `set-rest {line, rest}`,
`insert {after, text}` (`after: 0` inserts at the top), `delete {line}`. The
[Tracklist API reference](https://4matic.github.io/trackparse/reference/tracklist/) explains each one,
and the rules are in
-[SPEC R13](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md#r13-tracklists).
+[R13 of the spec](https://4matic.github.io/trackparse/reference/spec/#r13-tracklists).
`to_dict()` gives the camelCase JSON from
[`tracklist.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/tracklist.schema.json),
byte-identical to the JS package's output.
-Every line is parsed with `mode="tracklist"`, where the first spaced dash always separates artist
-and title. `parse()` accepts it too:
+Every line is parsed with [`mode="tracklist"`](https://4matic.github.io/trackparse/guides/tracklists/#tracklist-mode), where the
+first spaced dash always separates artist and title. `parse()` accepts it too:
```python
parse("Electrosoul System - Liquid Metal").junk
@@ -510,7 +527,7 @@ parse("Electrosoul System - Liquid Metal", mode="tracklist").title
## Errors
-Parsing is total: any `str` gives a complete `ParsedTrack`, `""` included, and `parse_tracklist`
+Parsing is total ([R0.8](https://4matic.github.io/trackparse/reference/spec/#r0-portability)): any `str` gives a complete `ParsedTrack`, `""` included, and `parse_tracklist`
and `apply_edits` return for any text. An option of the wrong type or with an unknown value is
ignored and the default is used. `apply_edits` reports a bad edit as an `edit-invalid` warning and
leaves the text alone.
@@ -560,7 +577,8 @@ The package ships `py.typed` and passes `mypy --strict`.
**Changelog:** [python/CHANGELOG.md](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md)
-The package version is the spec version (`SPEC_VERSION`). While it is 0.x, a release that changes
+The package version is the spec version ([`SPEC_VERSION`](#spec_version)); every release is on
+[PyPI](https://pypi.org/project/trackparse/). While it is 0.x, a release that changes
the output for some input bumps the minor version, and a patch release only fixes bugs. If you
store parsed results, pin the minor version (`trackparse~=0.6.0` stays on 0.6.x) and read the
changelog before moving up.
@@ -573,12 +591,12 @@ The same parser exists for JavaScript, Rust and Go. All four implement one spec,
fixtures, are released together under one version number, and return identical JSON for every
fixture input. You can parse in one language and read the result in another.
-| Language | Package | Install |
-|---|---|---|
-| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` |
-| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` |
-| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` |
-| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` |
+| Language | Package | Install | Docs |
+|---|---|---|---|
+| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/js/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/js/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) |
+| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) |
## Limitations
diff --git a/rust/README.md b/rust/README.md
index 7191146..c0385fa 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -6,7 +6,7 @@
[](https://github.com/4matic/trackparse/actions/workflows/rust.yml)
[](https://github.com/4matic/trackparse/blob/main/LICENSE)
-**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[API on docs.rs](https://docs.rs/trackparse)**
+**[Documentation](https://4matic.github.io/trackparse/)** · **[Getting started](https://4matic.github.io/trackparse/start/getting-started/)** · **[Playground](https://4matic.github.io/trackparse/playground/)** · **[API on docs.rs](https://docs.rs/trackparse)** · **[Changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md)**
**Turn messy track names into structured data: who made it, who's featured, who remixed it, and
what's just noise.**
@@ -18,17 +18,18 @@ what's just noise.**
Most title parsers split that into `"Wilkinson ft. Becky Hill & Tom Cane"` and
`"Afterglow (Sub Focus VIP Remix)"` and stop. Others "clean" it and throw the feat and the remix
away. trackparse keeps all of it. Everything it recognizes goes into a field, and anything it
-doesn't recognize stays in the title, word for word.
+doesn't recognize stays in the title, word for word
+([try it in the playground](https://4matic.github.io/trackparse/playground/#track=01.%20Wilkinson%20ft.%20Becky%20Hill%20%26%20Tom%20Cane%20-%20Afterglow%20%28Sub%20Focus%20VIP%20Remix%29%20%5BOfficial%20Video%5D)).
This is the Rust port of [trackparse](https://github.com/4matic/trackparse). Its behaviour is
-defined by a [shared spec](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md) and pinned
-by 13,130 fixtures. It passes all of them, and for every fixture input its output is byte-identical
+defined by a [shared spec](https://4matic.github.io/trackparse/reference/spec/) and pinned
+by [13,130 fixtures](https://4matic.github.io/trackparse/project/testing/). It passes all of them, and for every fixture input its output is byte-identical
to the [JavaScript, Python and Go packages](#other-languages).
- Rust 1.74 or later (the minimum supported version; CI runs the test suite on 1.74 and on stable)
- One dependency (`unicode-normalization`); `serde` is optional
- No `unsafe`, no regular expressions
-- Never panics and never returns an error: any `&str` gives a result
+- Never panics and never returns an error: any `&str` gives a result ([Errors](#errors))
## Install
@@ -68,8 +69,8 @@ assert_eq!(
);
```
-`to_json()` returns the spec's JSON form as compact text, with the same camelCase keys the
-JavaScript package uses:
+[`to_json()`](https://docs.rs/trackparse/latest/trackparse/struct.ParsedTrack.html#method.to_json) returns the spec's JSON form as compact
+text, with the same camelCase keys the JavaScript package uses ([JSON and serde](#json-and-serde)):
```rust
let track = trackparse::parse("Wilkinson ft. Becky Hill - Afterglow (Sub Focus VIP Remix) [HD]");
@@ -136,19 +137,25 @@ tracklist::apply_edits(text: &str, edits: &[Edit]) -> EditResult
tracklist::apply_edits_with(text: &str, edits: &[Edit], options: &TracklistOptions) -> EditResult
```
-Every function has a plain form with the default options and a `_with` form that takes them.
+Every function has a plain form with the default options and a `_with` form that takes them. Each
+has a section below, a page on [docs.rs](https://docs.rs/trackparse) and one in the
+[API reference](https://4matic.github.io/trackparse/reference/functions/), where every example has a Rust tab; the tracklist
+functions are under [Tracklists](#tracklists).
### `parse` and `ParseOptions`
-**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/)
+**Docs:** [parse and ParsedTrack](https://4matic.github.io/trackparse/reference/parse/) · [Options](https://4matic.github.io/trackparse/reference/options/) · [`parse`](https://docs.rs/trackparse/latest/trackparse/fn.parse.html), [`parse_with`](https://docs.rs/trackparse/latest/trackparse/fn.parse_with.html) and [`ParseOptions`](https://docs.rs/trackparse/latest/trackparse/struct.ParseOptions.html) on docs.rs
+
+Parses one track string, running [rules R1 to R9](https://4matic.github.io/trackparse/reference/spec/#r1-normalization) of the
+spec in order.
| Option | Default | |
|---|---|---|
-| `mode` | `ModeOption::Auto` | `Clean`, `Youtube`, `Filename`, `Tracklist`, or `Auto` to detect from the string. See [Modes](#modes) |
-| `uploader` | `None` | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
-| `known_artists` | empty | Names that are never split. There is no built-in list |
-| `split_and` | `SplitAnd::Auto` | `Auto` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `Always`, `Never` |
-| `keywords` | `None` | Extra vocabulary, added to the built-in lists (see below) |
+| [`mode`](https://4matic.github.io/trackparse/guides/modes/) | `ModeOption::Auto` | `Clean`, `Youtube`, `Filename`, `Tracklist`, or `Auto` to detect from the string. See [Modes](#modes) |
+| [`uploader`](https://4matic.github.io/trackparse/guides/modes/#the-uploader-fallback) | `None` | YouTube channel name, used as the artist when there's no separator (`- Topic` and `VEVO` are dropped) |
+| [`known_artists`](https://4matic.github.io/trackparse/guides/artists/#knownartists) | empty | Names that are never split. There is no built-in list |
+| [`split_and`](https://4matic.github.io/trackparse/guides/artists/#and-is-special) | `SplitAnd::Auto` | `Auto` splits on `and` only after a comma (`A, B and C`), so `Simon and Garfunkel` stays whole. Also `Always`, `Never` |
+| [`keywords`](https://4matic.github.io/trackparse/reference/options/#keywords) | `None` | Extra vocabulary, added to the built-in lists (see below) |
Options are built with chained setters. The structs are `#[non_exhaustive]`, so start from
`ParseOptions::new()` (or `default()`); the fields are public and can also be assigned.
@@ -171,7 +178,8 @@ assert_eq!(
);
```
-`KeywordOptions` adds words to the built-in lists:
+[`KeywordOptions`](https://docs.rs/trackparse/latest/trackparse/struct.KeywordOptions.html) adds words to the built-in lists
+([your own words](https://4matic.github.io/trackparse/guides/versions/#your-own-words)):
| Setter | Field | |
|---|---|---|
@@ -195,7 +203,7 @@ assert_eq!(track.junk[0].kind, JunkKind::Label);
### `ParsedTrack`
-**Docs:** [ParsedTrack fields](https://4matic.github.io/trackparse/reference/parse/#parsedtrack)
+**Docs:** [ParsedTrack fields](https://4matic.github.io/trackparse/reference/parse/#parsedtrack) · [`ParsedTrack`](https://docs.rs/trackparse/latest/trackparse/struct.ParsedTrack.html) on docs.rs
| Field | Type | |
|---|---|---|
@@ -240,10 +248,13 @@ assert_eq!(version.descriptor.as_deref(), Some("at Wembley"));
assert_eq!(version.year, Some(1986));
```
-Version types, junk kinds, warnings, roles and modes are enums (`VersionType`, `JunkKind`,
-`Warning`, `ArtistRole`, `ArtistSource`, `Mode`, `ModeOption`, `VersionDelimiter`), listed in the
-[API reference](https://4matic.github.io/trackparse/reference/parse/) and on
-[docs.rs](https://docs.rs/trackparse). Each has `as_str()` (the name
+Version types, junk kinds, warnings, roles and modes are enums
+([`VersionType`](https://docs.rs/trackparse/latest/trackparse/enum.VersionType.html), [`JunkKind`](https://docs.rs/trackparse/latest/trackparse/enum.JunkKind.html),
+[`Warning`](https://docs.rs/trackparse/latest/trackparse/enum.Warning.html), [`ArtistRole`](https://docs.rs/trackparse/latest/trackparse/enum.ArtistRole.html),
+[`ArtistSource`](https://docs.rs/trackparse/latest/trackparse/enum.ArtistSource.html), [`Mode`](https://docs.rs/trackparse/latest/trackparse/enum.Mode.html),
+[`ModeOption`](https://docs.rs/trackparse/latest/trackparse/enum.ModeOption.html), [`VersionDelimiter`](https://docs.rs/trackparse/latest/trackparse/enum.VersionDelimiter.html)),
+listed in the [API reference](https://4matic.github.io/trackparse/reference/parse/) ([the 27 version types](https://4matic.github.io/trackparse/guides/versions/#the-27-types),
+[junk kinds](https://4matic.github.io/trackparse/reference/parse/#junk-kinds)). Each has `as_str()` (the name
used in the spec and in JSON), `from_name()`, `ALL`, `Display` and `FromStr`:
```rust
@@ -262,7 +273,7 @@ warning, so a `match` on them needs a `_` arm.
**Docs:** [Serializing to JSON](https://4matic.github.io/trackparse/reference/parse/#serializing-to-json)
-Every result type has `to_json()`, which writes compact JSON matching
+Every result type has [`to_json()`](https://docs.rs/trackparse/latest/trackparse/struct.ParsedTrack.html#method.to_json), which writes compact JSON matching
[`parsed-track.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/parsed-track.schema.json)
and
[`tracklist.schema.json`](https://github.com/4matic/trackparse/blob/main/spec/schema/tracklist.schema.json)
@@ -311,7 +322,8 @@ Reading options is strict: a missing key is the default, an unknown name such as
**Docs:** [parseArtists](https://4matic.github.io/trackparse/reference/functions/#parseartistsinput-options) · [Artists and credits](https://4matic.github.io/trackparse/guides/artists/)
-Splits a bare artist string (no title). `parse_artists_with` takes the same options as `parse_with`.
+Splits a bare artist string (no title) ([R10](https://4matic.github.io/trackparse/reference/spec/#r10-parseartists)).
+[`parse_artists_with`](https://docs.rs/trackparse/latest/trackparse/fn.parse_artists_with.html) takes the same options as `parse_with`.
```rust
use trackparse::parse_artists;
@@ -327,7 +339,9 @@ assert_eq!(credits, ["Sub Focus:primary", "Wilkinson:primary", "Dimension:primar
**Docs:** [format](https://4matic.github.io/trackparse/reference/functions/#formattrack-options) · [Formatting](https://4matic.github.io/trackparse/guides/formatting/)
-Renders a track back to a string.
+Renders a track back to a string ([format options](https://4matic.github.io/trackparse/reference/options/#format-options),
+[R11](https://4matic.github.io/trackparse/reference/spec/#r11-format)): [`format_track`](https://docs.rs/trackparse/latest/trackparse/fn.format_track.html),
+[`format_track_with`](https://docs.rs/trackparse/latest/trackparse/fn.format_track_with.html), [`FormatOptions`](https://docs.rs/trackparse/latest/trackparse/struct.FormatOptions.html).
| Option | Default | |
|---|---|---|
@@ -373,8 +387,9 @@ assert_eq!(
**Docs:** [normalize](https://4matic.github.io/trackparse/reference/functions/#normalizeinput)
The Unicode cleanup every function runs first: NFC, zero-width spaces, BOM and soft hyphens
-removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed.
-Running it twice changes nothing.
+removed, fullwidth brackets, smart quotes and dash variants mapped to ASCII, whitespace collapsed
+([R1](https://4matic.github.io/trackparse/reference/spec/#r1-normalization)). Running it twice changes nothing
+([`normalize`](https://docs.rs/trackparse/latest/trackparse/fn.normalize.html)).
```rust
use trackparse::normalize;
@@ -386,7 +401,8 @@ assert_eq!(normalize("Noisia\u{200b} – Stigma (VIP)"), "Noisia - Stigma (V
**Docs:** [allArtists](https://4matic.github.io/trackparse/reference/functions/#allartiststrack)
-Credits plus every remixer, deduplicated.
+Credits plus every remixer, deduplicated ([R9](https://4matic.github.io/trackparse/reference/spec/#r9-assembly-and-dedup),
+[`all_artists`](https://docs.rs/trackparse/latest/trackparse/fn.all_artists.html)).
```rust
use trackparse::{all_artists, parse};
@@ -401,7 +417,8 @@ assert_eq!(credits, ["Wilkinson:primary", "Becky Hill:featured", "Sub Focus:remi
**Docs:** [createParser](https://4matic.github.io/trackparse/reference/functions/#createparseroptions)
-Resolves the options and builds the word tables once, for many calls. It is `Send + Sync`.
+[`Parser`](https://docs.rs/trackparse/latest/trackparse/struct.Parser.html) resolves the options and builds the word tables once, for many
+calls. It is `Send + Sync`.
```rust
use trackparse::{KeywordOptions, ParseOptions, Parser, VersionType};
@@ -418,21 +435,23 @@ assert_eq!(track.versions[0].version_type, VersionType::Rework);
### `SPEC_VERSION`
-The version of the spec this build implements. It equals the crate version: the crate, the npm
+**Docs:** [SPEC_VERSION](https://4matic.github.io/trackparse/reference/functions/#spec_version) · [`SPEC_VERSION`](https://docs.rs/trackparse/latest/trackparse/constant.SPEC_VERSION.html) on docs.rs
+
+The version of the [spec](https://4matic.github.io/trackparse/reference/spec/) this build implements. It equals the crate version: the crate, the npm
package, the PyPI package, the Go module and the spec are released together and always share one
version number.
## Modes
-**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/)
+**Docs:** [Modes](https://4matic.github.io/trackparse/guides/modes/) · [R2 in the spec](https://4matic.github.io/trackparse/reference/spec/#r2-mode-prelude) · [`ModeOption`](https://docs.rs/trackparse/latest/trackparse/enum.ModeOption.html) on docs.rs
| Mode | For | Adds |
|---|---|---|
| `Clean` | Store metadata, tags | Only a spaced dash separates artist and title |
-| `Youtube` | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
-| `Filename` | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
-| `Auto` | Anything | `Filename` for known extensions, `Youtube` when it sees junk, pipes or platform suffixes, `Clean` otherwise |
-| `Tracklist` | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `Auto` |
+| [`Youtube`](https://4matic.github.io/trackparse/guides/modes/#youtube-mode) | Video titles, scrobbles | Pipe segments, `"Title" by Artist`, `Artist: "Title"`, unspaced dashes, trailing junk, uploader fallback |
+| [`Filename`](https://4matic.github.io/trackparse/guides/modes/#filename-mode) | Files | Strips the extension, `_` becomes a space, `01-Track` numbering |
+| [`Auto`](https://4matic.github.io/trackparse/guides/modes/#how-auto-decides) | Anything | `Filename` for known extensions, `Youtube` when it sees junk, pipes or platform suffixes, `Clean` otherwise |
+| [`Tracklist`](https://4matic.github.io/trackparse/guides/modes/#tracklist-mode) | One line of a tracklist | The first spaced dash always separates; `_-_` too. Never picked by `Auto` |
```rust
use trackparse::{parse, parse_with, Mode, ModeOption, ParseOptions, Warning};
@@ -453,23 +472,26 @@ let track = parse_with("Shelter", &youtube.uploader("Porter Robinson"));
assert_eq!(track.artists[0].name, "Porter Robinson");
```
+Try [`"Numb" by Linkin Park` in youtube mode](https://4matic.github.io/trackparse/playground/#track=%22Numb%22%20by%20Linkin%20Park&mode=youtube) or
+[`07_Burial_-_Archangel.mp3`](https://4matic.github.io/trackparse/playground/#track=07_Burial_-_Archangel.mp3) in the playground.
+
## Warnings
-**Docs:** [Warnings](https://4matic.github.io/trackparse/reference/warnings/)
+**Docs:** [Warnings](https://4matic.github.io/trackparse/reference/warnings/) · [`Warning`](https://docs.rs/trackparse/latest/trackparse/enum.Warning.html) on docs.rs
The parser never fails, but it says when it had to guess. `track.warnings` is a `Vec`,
empty when every decision was unambiguous. `as_str()` gives the name used in the spec and in JSON.
| Warning | JSON name | Means |
|---|---|---|
-| `NoSeparator` | `noSeparator` | No artist/title separator was found. The whole string is the title |
-| `AmbiguousSeparator` | `ambiguousSeparator` | A two-part pipe title with no dash was read as artist and title |
-| `UnspacedDashSplit` | `unspacedDashSplit` | Split at a dash without spaces around it |
-| `AsymmetricDashSplit` | `asymmetricDashSplit` | Split at a dash with a space on one side only |
-| `BySplit` | `bySplit` | Read `"Title" by Artist` |
-| `QuotedTitleSplit` | `quotedTitleSplit` | Took a quoted span as the title and the text before it as the artist |
-| `AmbiguousMixCredit` | `ambiguousMixCredit` | ` Mix` was read as a remix, but the name is long enough to be a style |
-| `UnbalancedBrackets` | `unbalancedBrackets` | A bracket was opened and never closed |
+| `NoSeparator` | [`noSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=noSeparator) | No artist/title separator was found. The whole string is the title |
+| `AmbiguousSeparator` | [`ambiguousSeparator`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousSeparator) | A two-part pipe title with no dash was read as artist and title |
+| `UnspacedDashSplit` | [`unspacedDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unspacedDashSplit) | Split at a dash without spaces around it |
+| `AsymmetricDashSplit` | [`asymmetricDashSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=asymmetricDashSplit) | Split at a dash with a space on one side only |
+| `BySplit` | [`bySplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=bySplit) | Read `"Title" by Artist` |
+| `QuotedTitleSplit` | [`quotedTitleSplit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=quotedTitleSplit) | Took a quoted span as the title and the text before it as the artist |
+| `AmbiguousMixCredit` | [`ambiguousMixCredit`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=ambiguousMixCredit) | ` Mix` was read as a remix, but the name is long enough to be a style |
+| `UnbalancedBrackets` | [`unbalancedBrackets`](https://4matic.github.io/trackparse/reference/warnings/#track-warnings:~:text=unbalancedBrackets) | A bracket was opened and never closed |
```rust
use trackparse::{parse, Warning};
@@ -483,14 +505,14 @@ assert_eq!(track.warnings[0].as_str(), "noSeparator");
assert_eq!(parse("Noisia - Stigma (VIP").warnings, [Warning::UnbalancedBrackets]);
```
-Tracklists have their own warnings, with line numbers. They are listed under
-[Tracklists](#tracklists).
+Tracklists have their own [warnings](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings), with line numbers. They are listed
+under [Tracklists](#tracklists).
## Tracklists
**Docs:** [Tracklists](https://4matic.github.io/trackparse/guides/tracklists/) · [Editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/) · [Tracklist API](https://4matic.github.io/trackparse/reference/tracklist/) · [Warnings](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings)
-`trackparse::tracklist` parses a whole tracklist, one entry per line, and checks it. Each entry
+[`trackparse::tracklist`](https://docs.rs/trackparse/latest/trackparse/tracklist/index.html) parses a whole tracklist, one entry per line, and checks it. Each entry
keeps its line exactly as written plus its own line ending, so joining every `raw` and `eol` is
always the input, CRLF or not.
@@ -543,10 +565,12 @@ assert_eq!((stats.lines, stats.tracks, stats.markers, stats.timed), (9, 7, 1, 8)
assert_eq!((stats.first_time, stats.last_time), (Some(2900.0), Some(4536.0)));
```
-The suggestion exists because exactly one time, one digit away from `00:11:02`, fits between its
-neighbours. With several candidates or none, `suggestion` is `None`.
+The [suggestion](https://4matic.github.io/trackparse/reference/warnings/#suggestions) exists because exactly one time, one digit away from `00:11:02`,
+fits between its neighbours. With several candidates or none, `suggestion` is `None`.
+[Open this list in the playground](https://4matic.github.io/trackparse/playground/#list=Hour%202%0A48%3A20%20Noisia%20-%20Stigma%0A52%3A47%20Mefjus%20%26%20Kasra%20-%20Bandwagon%20%28Phace%20Remix%29%0A56%3A05%20Black%20Sun%20Empire%20-%20ID%0A59%3A31%20Alix%20Perez%20-%20Fade%20Away%0A01%3A03%3A10%20Interview%20with%20Hybris%0A01%3A07%3A44%20Imanu%20-%20Sacrifice%0A00%3A11%3A02%20Current%20Value%20feat.%20Teddy%20Killerz%20-%20Payload%0A01%3A15%3A36%20Hybris%20-%20Spinning%20Top).
-`apply_edits` takes a slice of `Edit` values and only rewrites the lines they name:
+[`apply_edits`](https://docs.rs/trackparse/latest/trackparse/tracklist/fn.apply_edits.html) takes a slice of [`Edit`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.Edit.html)
+values and only rewrites the lines they name:
```rust
use trackparse::tracklist::{apply_edits, Edit, EditWarningCode};
@@ -570,9 +594,11 @@ assert_eq!(result.warnings[0].code, EditWarningCode::TimeClamped);
A rewritten time keeps its line's style: `48:20` stays `MM:SS`, and a time that crosses the hour
gets hours, with a `style-upgraded` warning. A time pushed below zero stops at zero and warns
-`time-clamped`. A bad edit changes nothing and warns `edit-invalid`.
+`time-clamped`. A bad edit changes nothing and warns `edit-invalid`
+([edit warnings](https://4matic.github.io/trackparse/reference/warnings/#edit-warnings), [editing tracklists](https://4matic.github.io/trackparse/guides/editing-tracklists/#times-keep-their-style)).
-`TracklistOptions` has `mode` (default `ModeOption::Tracklist`), `known_artists`, `split_and`,
+[`TracklistOptions`](https://docs.rs/trackparse/latest/trackparse/tracklist/struct.TracklistOptions.html) ([options](https://4matic.github.io/trackparse/reference/options/#tracklist-options))
+has `mode` (default `ModeOption::Tracklist`), `known_artists`, `split_and`,
`keywords`, `audio_seconds` (enables `time-after-audio-end`) and `marker_words`:
```rust
@@ -602,7 +628,7 @@ previous one
([Markdown](https://4matic.github.io/trackparse/guides/tracklists/#markdown),
[layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)).
-Warning codes (`WarningCode`): `time-missing`, `time-out-of-order`, `time-duplicate`,
+[Warning codes](https://4matic.github.io/trackparse/reference/warnings/#tracklist-warnings) ([`WarningCode`](https://docs.rs/trackparse/latest/trackparse/tracklist/enum.WarningCode.html)): `time-missing`, `time-out-of-order`, `time-duplicate`,
`no-start-at-zero`, `time-after-audio-end` (needs `audio_seconds`), `invalid-time`, `position-gap`,
`position-duplicate`, `line-unparsed`. Edits: `Edit::set_time(line, seconds)`,
`Edit::shift(seconds)` (all timed lines), `Edit::shift_from(seconds, from)`,
@@ -610,10 +636,10 @@ Warning codes (`WarningCode`): `time-missing`, `time-out-of-order`, `time-duplic
`Edit::insert(after, text)` (`after: 0` inserts at the top), `Edit::delete(line)`. The
[Tracklist API reference](https://4matic.github.io/trackparse/reference/tracklist/) explains each
one, and the rules are in
-[SPEC R13](https://github.com/4matic/trackparse/blob/main/spec/SPEC.md#r13-tracklists).
+[R13 of the spec](https://4matic.github.io/trackparse/reference/spec/#r13-tracklists).
-Every line is parsed with `ModeOption::Tracklist`, where the first spaced dash always separates
-artist and title. `parse_with` accepts it too:
+Every line is parsed with [`ModeOption::Tracklist`](https://4matic.github.io/trackparse/guides/tracklists/#tracklist-mode), where the
+first spaced dash always separates artist and title. `parse_with` accepts it too:
```rust
use trackparse::{parse, parse_with, JunkKind, ModeOption, ParseOptions};
@@ -628,13 +654,14 @@ assert_eq!(parse_with("Electrosoul System - Liquid Metal", &options).title, "Liq
## Errors
-No function returns a `Result` and none panics. `parse` gives a complete `ParsedTrack` for any
+No function returns a `Result` and none panics ([R0.8](https://4matic.github.io/trackparse/reference/spec/#r0-portability)). `parse` gives a complete `ParsedTrack` for any
`&str`, `""` included, and `parse_tracklist` and `apply_edits` return for any text. Options are
typed, so a wrong value does not compile. `apply_edits` reports an edit it cannot apply (a line
that does not exist, non-finite seconds) as an `EditWarningCode::EditInvalid` warning and leaves
the text alone.
-The only fallible calls are conversions from text: `FromStr` on the enums returns `UnknownName`
+The only fallible calls are conversions from text: `FromStr` on the enums returns
+[`UnknownName`](https://docs.rs/trackparse/latest/trackparse/struct.UnknownName.html)
for a name the spec does not have, and with the `serde` feature, deserializing options or edits
from JSON can fail as any `serde` type can.
@@ -646,7 +673,7 @@ from JSON can fail as any `serde` type can.
the rules), the spec's invariants for single tracks and for tracklists on generated input (no
panic in any mode, `normalize` idempotent, the format round trip, no word lost, timing), and the
API tests. The skip list is empty.
-- `scripts/compare-ports.mjs` in the repository runs every fixture input through the JavaScript
+- [`scripts/compare-ports.mjs`](https://github.com/4matic/trackparse/blob/main/scripts/compare-ports.mjs) in the repository runs every fixture input through the JavaScript
package and this crate and compares the complete JSON output, every field of it, not only the
ones a fixture asserts. The Python package and the Go module are checked the same way.
- The Unicode facts the rules need (letters, uppercase letters, lowercase mapping) are tables
@@ -661,7 +688,7 @@ from JSON can fail as any `serde` type can.
## Unicode version
Normalization (NFC in `normalize`, NFD in the key that finds duplicate artists) comes from the
-`unicode-normalization` crate and follows its Unicode version. This crate requires 0.1.26 or
+[`unicode-normalization`](https://crates.io/crates/unicode-normalization) crate and follows its Unicode version. This crate requires 0.1.26 or
later, which has the Unicode 18 tables; older releases have older tables and give other results
for some strings, so Cargo will not select them.
@@ -669,7 +696,8 @@ The JavaScript package normalizes with its runtime's tables, which are Unicode 1
Unicode 18 added 32 combining marks, so a string that contains one of them can come out with its
marks in another order here than in JavaScript on that runtime, and than in the Go module, whose
NFC and NFD tables are generated from Node 24. Strings without those marks are not affected, and
-every shared fixture gives the same bytes.
+every shared fixture gives the same bytes. More in
+[what the Rust port taught](https://4matic.github.io/trackparse/project/ports/#what-the-rust-port-taught).
## Performance
@@ -681,7 +709,8 @@ length (thousands of duplicate credits, bracket groups or junk phrases) under a
**Changelog:** [rust/CHANGELOG.md](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md)
-The crate version is the spec version (`SPEC_VERSION`). While it is 0.x, a release that changes
+The crate version is the spec version ([`SPEC_VERSION`](#spec_version)); every release is on
+[crates.io](https://crates.io/crates/trackparse/versions). While it is 0.x, a release that changes
the output for some input bumps the minor version, and a patch release only fixes bugs. Cargo's
default requirement already stays within one minor version (`trackparse = "0.6"` means 0.6.x), so
`cargo update` only brings fixes. Read the changelog before moving to the next minor.
@@ -695,12 +724,12 @@ fixtures, are released together under one version number, and return identical J
fixture input. You can parse in one language and read the result in another. The one known
difference is described under [Unicode version](#unicode-version).
-| Language | Package | Install |
-|---|---|---|
-| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` |
-| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` |
-| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` |
-| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` |
+| Language | Package | Install | Docs |
+|---|---|---|---|
+| JavaScript / TypeScript | [trackparse on npm](https://www.npmjs.com/package/trackparse) | `npm install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/js/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/js/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Python | [trackparse on PyPI](https://pypi.org/project/trackparse/) | `pip install trackparse` | [README](https://github.com/4matic/trackparse/blob/main/python/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/python/CHANGELOG.md) · [API](https://4matic.github.io/trackparse/reference/parse/) |
+| Rust | [trackparse on crates.io](https://crates.io/crates/trackparse) | `cargo add trackparse` | [README](https://github.com/4matic/trackparse/blob/main/rust/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/rust/CHANGELOG.md) · [API on docs.rs](https://docs.rs/trackparse) |
+| Go | [github.com/4matic/trackparse/go](https://pkg.go.dev/github.com/4matic/trackparse/go) | `go get github.com/4matic/trackparse/go` | [README](https://github.com/4matic/trackparse/blob/main/go/README.md) · [changelog](https://github.com/4matic/trackparse/blob/main/go/CHANGELOG.md) · [API on pkg.go.dev](https://pkg.go.dev/github.com/4matic/trackparse/go) |
## Limitations
diff --git a/site/src/components/Features.astro b/site/src/components/Features.astro
index f49f5fd..1743545 100644
--- a/site/src/components/Features.astro
+++ b/site/src/components/Features.astro
@@ -3,6 +3,8 @@
interface Item {
title: string;
body: string;
+ /** The guide that explains the item: the title links there. */
+ href?: string;
}
const { items } = Astro.props as { items: Item[] };
---
@@ -12,7 +14,7 @@ const { items } = Astro.props as { items: Item[] };
items.map((it, i) => (