From b199b9728b82a8626c6c0d619b0a10a281de9733 Mon Sep 17 00:00:00 2001 From: 4matic Date: Wed, 11 Nov 2026 01:09:17 +0200 Subject: [PATCH 1/2] docs(site): a Markdown sample in the playground, layered rows, and tracklist examples The playground gets a "Pasted with Markdown" sample (bullets, bold times, a w/ line) and a w/ chip on layered rows; loading a sample clears the edit log and the undo history. The editing guide shows that edits keep bullets and emphasis around a time, What it understands gets a tracklist table, and the tracklist guide, reference and testing pages describe emphasis next to the time and layered lines as the spec does. --- site/src/components/Playground.astro | 37 ++++++++++++++++--- .../docs/guides/editing-tracklists.mdx | 36 ++++++++++++++++++ site/src/content/docs/guides/tracklists.mdx | 10 +++-- .../docs/guides/what-it-understands.md | 15 ++++++++ site/src/content/docs/project/testing.md | 3 +- site/src/content/docs/reference/tracklist.mdx | 2 +- 6 files changed, 92 insertions(+), 11 deletions(-) diff --git a/site/src/components/Playground.astro b/site/src/components/Playground.astro index f368e6d..9b319f8 100644 --- a/site/src/components/Playground.astro +++ b/site/src/components/Playground.astro @@ -30,6 +30,17 @@ const sample = [ "00:11:02 Current Value feat. Teddy Killerz - Payload", "01:15:36 Hybris - Spinning Top", ].join("\n"); + +// Pasted from a chat or a comment: list bullets, Markdown emphasis and a layered `w/` line. +const markdownSample = [ + "**Tracklist**", + "* 00:00 Noisia - Stigma", + "* 03:30 **Phace** - Psycho", + "**[**07:10**] 3. Mefjus - Sleepless**", + "w/ Hybris - Spinning Top (Acapella)", + "[10:45] Imanu - _Sacrifice_", + "* 14:20 Black Sun Empire - ID", +].join("\n"); ---
@@ -151,7 +162,13 @@ const sample = [
- +
@@ -171,6 +188,7 @@ const sample = [
+

@@ -593,8 +611,10 @@ const sample = [ const title = t ? escapeHtml(t.title) : `${escapeHtml(e.raw.trim())}`; const vers = t ? t.versions.map((v) => chip(v.artists[0] ? `${v.type} · ${v.artists[0].name}` : v.type, "version")).join(" ") : ""; const pos = t?.position ? `${chip(`#${t.position.number}`, "position")} ` : ""; + // R13.13: a `w/` line plays over the previous track. + const layered = e.layered ? `${chip("w/", "position", "Layered: played over the previous track")} ` : ""; const cls = [warn ? "is-warn" : "", changed.has(e.line) ? "is-changed" : ""].join(" ").trim(); - return `${e.line}${e.kind}${e.time ? escapeHtml(e.time.raw) : ""}${pos}${artists}${title}${vers}`; + return `${e.line}${e.kind}${e.time ? escapeHtml(e.time.raw) : ""}${layered}${pos}${artists}${title}${vers}`; } function plural(n: number, word: string): string { @@ -703,10 +723,17 @@ const sample = [ $("tl-editlog").textContent = "Undone."; renderList(); }); - $("tl-sample").addEventListener("click", () => { - tl.value = tl.dataset.sample ?? ""; + // A sample replaces the text: the edit log and the undo history belong to the old one. + function loadSample(text: string | undefined) { + tl.value = text ?? ""; + history_.length = 0; + undoBtn.disabled = true; + changed.clear(); + $("tl-editlog").textContent = ""; renderList(); - }); + } + $("tl-sample").addEventListener("click", () => loadSample(tl.dataset.sample)); + $("tl-sample-markdown").addEventListener("click", () => loadSample(tl.dataset.sampleMarkdown)); // ---- start ------------------------------------------------------------------------------- input.value = document.querySelector("[data-example]")?.dataset.example ?? ""; diff --git a/site/src/content/docs/guides/editing-tracklists.mdx b/site/src/content/docs/guides/editing-tracklists.mdx index 7bbd190..641f3a2 100644 --- a/site/src/content/docs/guides/editing-tracklists.mdx +++ b/site/src/content/docs/guides/editing-tracklists.mdx @@ -100,6 +100,42 @@ When a time without hours crosses the hour, it gains hours in the style the rest (`59:31` → `01:00:16`, or `1:00:16` if the list writes one-digit hours). The edit reports `style-upgraded` so you know the line got longer. +## Bullets and Markdown stay + +A list bullet or Markdown emphasis around a time sits in `lead` and `gap`, so a rewritten time keeps +it. Only the digits change: + + + + +```js +const text = "**[**52:47**] Mefjus - Bandwagon**\n**[**59:31**] Alix Perez - Fade Away**"; +const result = applyEdits(text, [{ op: "shift", seconds: 45 }]); + +result.text; +// '**[**53:32**] Mefjus - Bandwagon**\n**[**01:00:16**] Alix Perez - Fade Away**' +result.warnings; // [ { code: 'style-upgraded', edit: 0, line: 2 } ] +``` + + + + +```python +text = "**[**52:47**] Mefjus - Bandwagon**\n**[**59:31**] Alix Perez - Fade Away**" +result = apply_edits(text, [{"op": "shift", "seconds": 45}]) + +result.text +# '**[**53:32**] Mefjus - Bandwagon**\n**[**01:00:16**] Alix Perez - Fade Away**' +result.warnings # (EditWarning(code='style-upgraded', edit=0, line=2),) +``` + + + + +`set-rest` replaces everything after the gap, including a closing `**` at the end of the line. The +time is still read afterwards, because emphasis next to a time doesn't need a partner. A layered +`w/` line without a time moves with the timed line above it when you sort. + ## When an edit can't apply Edits never throw. A bad one changes nothing and reports why: diff --git a/site/src/content/docs/guides/tracklists.mdx b/site/src/content/docs/guides/tracklists.mdx index 282bab3..a3f4b71 100644 --- a/site/src/content/docs/guides/tracklists.mdx +++ b/site/src/content/docs/guides/tracklists.mdx @@ -175,9 +175,10 @@ b.track.title # 'Stigma' -A `*` or `_` only counts as emphasis when it has a partner on the same line and sits against a -space, a bracket or the end of the line on its outer side. So names keep their stars and -underscores: `P*nk`, `*NSYNC`, `DJ_Name`, `Noisia_-_Stigma` and a censored `F**k` come out as +Right next to the time, a run of one or two `*` or `_` is read as emphasis by its position, with or +without a partner, so `**14:21 Artist - Title` still has its time. Anywhere else, a `*` or `_` only +counts when it has a partner on the same line and its outer side is a space, a bracket, another `*` +or `_`, or the end of the line. So names keep their stars and underscores: `P*nk`, `*NSYNC`, `DJ_Name`, `Noisia_-_Stigma` and a censored `F**k` come out as written. Runs of three or more, `~~`, `||` and backticks are never treated as Markdown. ## Layered tracks @@ -218,7 +219,8 @@ tl.warnings # () -Only a leading `w/` (or `W/`) followed by a space counts. `w/` inside a line +Only `w/` (or `W/`) at the start of the track text, after any time or bullet, and followed by +whitespace and a track counts, so `00:30 w/ Phace - Psycho` is layered too. `w/` inside a line (`Noisia w/ Phace - Stigma`), right after a track number (`10. w/ …`) or glued to the name (`w/Noisia`) is left alone, and so are `with`, `+` and `x`. diff --git a/site/src/content/docs/guides/what-it-understands.md b/site/src/content/docs/guides/what-it-understands.md index 0fd6a93..437fcde 100644 --- a/site/src/content/docs/guides/what-it-understands.md +++ b/site/src/content/docs/guides/what-it-understands.md @@ -57,6 +57,21 @@ it stays in the title. That's the rule: anything unrecognised is left alone. are fine guesses on YouTube and bad ones in a music library, so the default `clean` mode won't make them. In `youtube` mode it does, and it tells you through `warnings`. See [Modes](/trackparse/guides/modes/). +## In a tracklist + +Lines of a pasted tracklist go through +[`parseTracklist`](/trackparse/guides/tracklists/), which also reads list bullets, Markdown +emphasis and `w/` lines. Each input below is one line; click it to open it in the playground's +tracklist tab. + +| Line | Artists | Title | Other fields | +|---|---|---|---| +| [`* 00:00 Noisia - Stigma`](/trackparse/playground/#list=*%2000%3A00%20Noisia%20-%20Stigma) | Noisia | `Stigma` | time 0 s, bullet in `lead` | +| [`**[**00:00**] 10. Nitepunk - ID**`](/trackparse/playground/#list=**%5B**00%3A00**%5D%2010.%20Nitepunk%20-%20ID**) | Nitepunk | `ID` | time 0 s, position 10, `**` kept in `parts` | +| [`00:00 **Noisia** - _Stigma_`](/trackparse/playground/#list=00%3A00%20**Noisia**%20-%20_Stigma_) | Noisia | `Stigma` | time 0 s | +| [`w/ Nitepunk & Habstrakt - Point`](/trackparse/playground/#list=w%2F%20Nitepunk%20%26%20Habstrakt%20-%20Point) | Nitepunk, Habstrakt | `Point` | layered | +| [`00:00 P*nk - Raise Your Glass`](/trackparse/playground/#list=00%3A00%20P*nk%20-%20Raise%20Your%20Glass) | P\*nk | `Raise Your Glass` | the star stays | + ## By topic - [Artists and credits](/trackparse/guides/artists/): joiners, features, producers, `knownArtists`. diff --git a/site/src/content/docs/project/testing.md b/site/src/content/docs/project/testing.md index f0021b4..d0f391a 100644 --- a/site/src/content/docs/project/testing.md +++ b/site/src/content/docs/project/testing.md @@ -65,7 +65,8 @@ For tracklists, on random multi-line text and random edit lists: - `applyEdits(t, [])` returns `t`, and an edit never touches a line it doesn't name; - shifting forward and back restores the text, unless something was clamped or upgraded; - 10,000 lines parse in linear time (the JS suite allows 3 s; it takes about 0.6 s); -- Markdown emphasis around a time or a track line changes nothing. +- Markdown emphasis around a time or a track line gives the same kind, time and track as the plain + line. ## Port against port diff --git a/site/src/content/docs/reference/tracklist.mdx b/site/src/content/docs/reference/tracklist.mdx index 76fcf20..fed167c 100644 --- a/site/src/content/docs/reference/tracklist.mdx +++ b/site/src/content/docs/reference/tracklist.mdx @@ -72,7 +72,7 @@ One per line, in order. | `parts` | `{ lead, time, gap, rest }` | `raw` cut into four strings that join back into it | | `time` | `{ raw, seconds } \| null` | The start time | | `track` | `ParsedTrack \| null` | Parsed from `rest` in tracklist mode, without its [Markdown emphasis](/trackparse/guides/tracklists/#markdown), a leading `w/` and a bare track number. Only `track` and `marker` lines have one | -| `layered` | `boolean` | The line starts with `w/`: a [layered track](/trackparse/guides/tracklists/#layered-tracks), played over the previous one | +| `layered` | `boolean` | The track text (after any time) starts with `w/` and a space: a [layered track](/trackparse/guides/tracklists/#layered-tracks), played over the previous one | ### TracklistWarning From b8cfe09b518b5a6b6c80ad88bbe54527f05573f8 Mon Sep 17 00:00:00 2001 From: 4matic Date: Wed, 11 Nov 2026 01:09:17 +0200 Subject: [PATCH 2/2] docs: describe emphasis next to the time and layered lines as the spec does Emphasis next to a time needs no partner, layered is about the track text after any time, and the bundle size is in KiB. --- README.md | 21 ++++++++++++--------- js/README.md | 3 ++- python/README.md | 5 +++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f5035fb..7eed57c 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ Every key is always present. When a guess was involved, `warnings` says which on | **1,233** of them on tracklists | 297 handwritten, 936 generated. Line splitting, times, bullets and Markdown, warnings, edits | | **1,346** 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, … | -| **0** dependencies | ESM + CJS + TypeScript types, about 17 kB gzipped. `trackparse/tracklist` adds about 8.3 kB, only if you import it | +| **0** dependencies | ESM + CJS + TypeScript types, about 17 kB gzipped. `trackparse/tracklist` adds about 8.3 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,336 pytest tests on 3.9 to 3.14, plus every fixture against the built wheel. Output is byte-identical to JS | | **5,031** real tracklist lines | 117 podcast tracklists the tracklist rules were checked against. Every line round-trips byte for byte | @@ -313,12 +313,14 @@ apply_edits(text, [{"op": "set-time", "line": 8, "seconds": 4262}]).changed # (8,) ``` -Lists pasted from Discord, Reddit or YouTube comments often keep their list bullets and Markdown. -`* 14:21 Artist - Title`, `**[**14:21**] 10. Artist - Title**` and `[14:21] **Artist** - _Title_` -all read like the plain line; the decoration stays in `raw` and `parts`. A `*` or `_` only counts as -emphasis when it has a partner on the line and sits against a space, a bracket or the line's end, so -`P*nk`, `DJ_Name` and a censored `F**k` keep their stars and underscores -([details](https://4matic.github.io/trackparse/guides/tracklists/#markdown)). +Lists pasted from Discord, Reddit, Telegram or YouTube comments often keep their list bullets and +Markdown. `* 14:21 Artist - Title`, `**[**14:21**] 10. Artist - Title**` and +`[14:21] **Artist** - _Title_` all read like the plain line; the decoration stays in `raw` and +`parts`. Away from the time, a `*` or `_` only counts as emphasis when it has a partner on the line, +so `P*nk`, `DJ_Name` and a censored `F**k` keep their stars and underscores +([details](https://4matic.github.io/trackparse/guides/tracklists/#markdown)). A line whose track +text starts with `w/` is `layered`: a track played over the previous one +([layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)). ### Tracklist mode @@ -422,7 +424,8 @@ For tracklists, on random multi-line text and random edit lists: - 10,000 lines parse in linear time (the JS suite allows 3 s; it takes about 0.6 s); - a one-line list gives the same track as `parse()` in tracklist mode on its text without Markdown emphasis or a leading `w/`; -- Markdown emphasis around a time or a track line changes nothing. +- Markdown emphasis around a time or a track line gives the same kind, time and track as the plain + line. ### Real tracklists @@ -570,7 +573,7 @@ that only parses single tracks never loads it. | `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) | | `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 line starts with `w/`: 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 | 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 diff --git a/js/README.md b/js/README.md index fbab782..3f63022 100644 --- a/js/README.md +++ b/js/README.md @@ -291,7 +291,8 @@ exactly one fix fits), `time-duplicate`, `no-start-at-zero`, `time-after-audio-e Lists pasted with list bullets or Markdown emphasis (`* 14:21 Artist - Title`, `**[**14:21**] Artist - Title**`) read like plain lines; the decoration stays in `raw` and `parts`. -A line starting with `w/` is `layered`: a track played over the previous one +A line whose track text (after any time) starts with `w/` is `layered`: a track played over the +previous one ([Markdown](https://4matic.github.io/trackparse/guides/tracklists/#markdown), [layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)). diff --git a/python/README.md b/python/README.md index fa22e2c..d648579 100644 --- a/python/README.md +++ b/python/README.md @@ -428,7 +428,7 @@ apply_edits(text, edits, *, ) -> EditResult | Result | Fields | |---|---| | `Tracklist` | `spec_version`, `entries`, `warnings`, `stats` | -| `TracklistEntry` | `line` (1-based), `kind` (`track`, `marker`, `header`, `link`, `note`, `blank`), `eol`, `raw`, `parts`, `time`, `track` (`ParsedTrack` or `None`), `layered` (the line starts with `w/`) | +| `TracklistEntry` | `line` (1-based), `kind` (`track`, `marker`, `header`, `link`, `note`, `blank`), `eol`, `raw`, `parts`, `time`, `track` (`ParsedTrack` or `None`), `layered` (the track text after any time starts with `w/`) | | `Parts` | `lead`, `time`, `gap`, `rest`, joined they give `raw` | | `TracklistWarning` | `code`, `line`, `severity` (`info` or `warning`), `suggestion` | | `TimeValue` | `raw`, `seconds` (`entry.time`, or `None` on untimed lines) | @@ -438,7 +438,8 @@ apply_edits(text, edits, *, ) -> EditResult Lists pasted with list bullets or Markdown emphasis (`* 14:21 Artist - Title`, `**[**14:21**] Artist - Title**`) read like plain lines; the decoration stays in `raw` and `parts`. -A line starting with `w/` is `layered`: a track played over the previous one +A line whose track text (after any time) starts with `w/` is `layered`: a track played over the +previous one ([Markdown](https://4matic.github.io/trackparse/guides/tracklists/#markdown), [layered tracks](https://4matic.github.io/trackparse/guides/tracklists/#layered-tracks)).