diff --git a/.github/release-notes/0.4.0.md b/.github/release-notes/0.4.0.md new file mode 100644 index 0000000..c58ec6f --- /dev/null +++ b/.github/release-notes/0.4.0.md @@ -0,0 +1,39 @@ +Tracklists pasted from Discord, Reddit, Telegram or YouTube comments often keep their list bullets and Markdown, and DJ sets mark a track played over the previous one with `w/`. 0.3 read none of that: the time was lost and the decoration ended up in artist names. 0.4.0 reads through it, in both packages. + +```js +import { applyEdits, parseTracklist } from "trackparse/tracklist"; + +const text = [ + "* 00:00 Noisia - Stigma", + "**[**03:30**] Phace - Psycho**", + "w/ Mefjus - Sleepless (Acapella)", + "[07:10] **Imanu** - _Sacrifice_", +].join("\n"); + +const list = parseTracklist(text); +list.entries.map((e) => [e.time?.seconds ?? null, e.layered, e.track.artists[0].name, e.track.title]); +// [ [ 0, false, 'Noisia', 'Stigma' ], +// [ 210, false, 'Phace', 'Psycho' ], +// [ null, true, 'Mefjus', 'Sleepless' ], +// [ 430, false, 'Imanu', 'Sacrifice' ] ] +list.entries[1].parts; // { lead: '**[**', time: '03:30', gap: '**] ', rest: 'Phace - Psycho**' } +list.warnings; // [] + +applyEdits(text, [{ op: "shift", seconds: 15, from: 2 }]).text.split("\n")[1]; +// '**[**03:45**] Phace - Psycho**' +``` + +### What's new + +- **List bullets before a time.** `* 14:21 Artist - Title`, `- [01:02] Artist - Title` and `• 1:02:03 - …` keep their time. The bullet goes into `lead`. +- **Markdown emphasis.** `**bold**`, `__underline__`, `*italic*` and `_italic_` around the time, a name, a title or the whole line are read through. Nothing is removed from `raw` or `parts`: emphasis next to the time sits in `lead` and `gap` (so edits keep it), and the parser reads the rest of the line without it. + - Next to the time, a run of one or two `*` or `_` counts by its position, with or without a partner. Anywhere else, a `*` or `_` only counts when it has a partner on the line and its outer side is a space, a bracket, another `*` or `_`, or the line's end, so `P*nk`, `*NSYNC`, `DJ_Name`, `Noisia_-_Stigma` and a censored `F**k` stay as written. Backticks, `~~` and `||` are never Markdown. + - `**Intro**` is now a marker and `**Part 2:**` a header. +- **Layered `w/` lines.** A line whose track text (after any time or bullet) starts with `w/` and whitespace is a track played over the previous one: the entry has `layered: true`, and the `w/` no longer ends up in the first artist's name. An untimed layered line doesn't warn `time-missing`, and it doesn't break bare track numbering. + +### Upgrading + +- Every tracklist entry has a new key, `layered` (boolean). Code that checks the exact set of keys, or a schema copied from an older version, needs it added. +- Plain lines, without bullets, Markdown or `w/`, parse the same as in 0.3. On the private corpus of 5,031 real podcast tracklist lines, the output is identical to 0.3.3 apart from `layered: false`. +- `parse()` for single tracks is unchanged in every mode. +- `trackparse/tracklist` now adds about 8.3 KiB gzipped (was 7.6 KiB); the CI budget is 9 KiB.