···11# Changelog
2233+## 2.0.1 - 2026-06-15
44+55+- Fixed a bug where newline characters would be displayed as escaped when
66+ displaying a snapshot title containing one.
77+38## 2.0.0 - 2026-05-03
49510- Birdie snapshots are now located under the `test/birdie_snapshots` directory.
···386386 content,
387387 )) ->
388388 Ok(Snapshot(
389389- title: string.trim(title),
389389+ title: unescape_title(title) |> string.trim,
390390 content: trim_content(content, based_on: version),
391391 info: None,
392392 ))
···416416 content,
417417 )) ->
418418 Ok(Snapshot(
419419- title: string.trim(title),
419419+ title: unescape_title(title) |> string.trim,
420420 content: trim_content(content, based_on: version),
421421 info: Some(SnapshotInfo(
422422 file: string.trim(file),
···429429 }
430430}
431431432432+fn unescape_title(title: String) -> String {
433433+ // All backslashes have been escaped as "\\\\"
434434+ string.split(title, on: "\\\\")
435435+ |> list.map(string.replace(in: _, each: "\\n", with: "\n"))
436436+ |> string.join(with: "\\")
437437+}
438438+439439+fn escape_title(title: String) -> String {
440440+ // We escape newlines and backslash so that the title will be on a single line
441441+ // in the file once it's saved.
442442+ string.replace(title, each: "\n", with: "\\n")
443443+ |> string.replace(each: "\\", with: "\\\\")
444444+}
445445+432446/// Birdie started adding newlines to the end of files starting from `1.4.0`,
433447/// so if we're reading a snapshot created from `1.4.0` onwards then we want to
434448/// make sure to remove that newline!
···466480 // easier to parse.
467481 // Is this the best course of action? Probably not.
468482 // Does this make my life a lot easier? Absolutely! 😁
469469- "title: " <> string.replace(title, each: "\n", with: "\\n"),
483483+ "title: " <> escape_title(title),
470484 ],
471485 info_lines,
472486 ["---", content],
···1616 |> birdie.snap(title: "a result test")
1717}
18181919+pub fn newlines_in_title_are_shown_normally_test() {
2020+ string.inspect("this snapshot's title should be on two lines")
2121+ |> birdie.snap(title: "this title\n contains a newline")
2222+}
2323+2424+pub fn escaped_newlines_in_title_stay_escaped_test() {
2525+ string.inspect("this snapshot's title should be on two lines")
2626+ |> birdie.snap(title: "this title\\n is displayed on a single line")
2727+}
2828+1929pub fn list_test() {
2030 "[ 1, 2, 3, 4 ]"
2131 |> birdie.snap(title: "list test")