diff --git a/corpus/styles/candidate/.snowbound/themes.json b/corpus/styles/candidate/.snowbound/themes.json index 23fc2f6d5ab4d043bdab59d4ce4a64e2ccf6a2b1..4226939c96a0cb780de25dae582b78ca1533ccaa 100644 --- a/corpus/styles/candidate/.snowbound/themes.json +++ b/corpus/styles/candidate/.snowbound/themes.json @@ -3,30 +3,30 @@ "assignments": [ { "scope": { - "section": "f0eb3316ed995d4f9a403ead450892a1" + "section": "c97f7483f6275a4cae47ddc5ad710f92" }, "theme": "onenote", "assigned": 134000000000000000 }, { "scope": { - "section": "13d8c0f86a617e4cb35733d2e514408f" + "section": "1fdd373a3fce75438aa4f7cb3aab4dd5" }, "theme": "manuscript", "assigned": 134000000000000000 }, { "scope": { - "section": "aae44a30901cff4aaca7fadf0c8bf659" + "section": "6bca798e361a7f41955ee1e3347e735c" }, "theme": "editorial", "assigned": 134000000000000000 }, { "scope": { - "section": "709fb4685c18f945a24f9aa162fc78e4" + "section": "34672277dc8b1d40a919ac2d706ef3e3" }, - "theme": "modern-2", + "theme": "modern-3", "assigned": 134000000000000000 } ] diff --git a/corpus/styles/candidate/Editorial.one b/corpus/styles/candidate/Editorial.one index 24ed6e93c7f9f84e53328a7b75e492de54dd8aba..96faa9f5f2fd2d61a0b370e0e645655687cb9df0 100644 Binary files a/corpus/styles/candidate/Editorial.one and b/corpus/styles/candidate/Editorial.one differ diff --git a/corpus/styles/candidate/Manuscript.one b/corpus/styles/candidate/Manuscript.one index 2debba02524ead50186d43e9b237e716e3766b6a..2400768add3af574d8ff89700ee9882432b23934 100644 Binary files a/corpus/styles/candidate/Manuscript.one and b/corpus/styles/candidate/Manuscript.one differ diff --git a/corpus/styles/candidate/Modern.one b/corpus/styles/candidate/Modern.one index 4a38d76d1405c3de7884eeaee32346e0659d567f..1d72d374f74ecb3aff92b8e49edb3f1269bc3c33 100644 Binary files a/corpus/styles/candidate/Modern.one and b/corpus/styles/candidate/Modern.one differ diff --git a/corpus/styles/candidate/OneNote.one b/corpus/styles/candidate/OneNote.one index 91a55e1519e618291e533fea933417773a9e4751..e1be67d72b44c806f4468a959d7ee904111eb1ed 100644 Binary files a/corpus/styles/candidate/OneNote.one and b/corpus/styles/candidate/OneNote.one differ diff --git a/corpus/styles/candidate/Open Notebook.onetoc2 b/corpus/styles/candidate/Open Notebook.onetoc2 index a0d64387026996a2b08255213ee699d343223d6b..361d18e4c43cc9fcfc192734415f8d80a0290598 100644 Binary files a/corpus/styles/candidate/Open Notebook.onetoc2 and b/corpus/styles/candidate/Open Notebook.onetoc2 differ diff --git a/corpus/styles/cold/commands.jsonl b/corpus/styles/cold/commands.jsonl index 746eea2f97bf65d2e89558bee279d263bc14fc74..c61079a0b9f15449a32b5b66e920e8bcd2327887 100644 --- a/corpus/styles/cold/commands.jsonl +++ b/corpus/styles/cold/commands.jsonl @@ -1,4 +1,4 @@ {"command": "powershell -NoProfile -Command \"Expand-Archive -LiteralPath C:\\one-tests\\transfer.zip -DestinationPath C:\\one-tests\\runs\\capture\\notebook\"", "exit": 0, "stdout": "", "stderr": "", "error": null} -{"command": "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File C:\\one-tests\\author.ps1 -Root C:\\one-tests\\runs\\capture -CloneHost ONE-M6-F5FCF7CA", "exit": 0, "stdout": "", "stderr": "", "error": null} -{"command": "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File C:\\one-tests\\read-current.ps1 -Root C:\\one-tests\\runs\\capture -CloneHost ONE-M6-F5FCF7CA -ExpectedPages 4 -UseCurrentCache -KeepOpen", "exit": 0, "stdout": "Read 4 sections and 4 pages.\r\n", "stderr": "", "error": null} +{"command": "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File C:\\one-tests\\author.ps1 -Root C:\\one-tests\\runs\\capture -CloneHost ONE-M6-8C0AB998", "exit": 0, "stdout": "", "stderr": "", "error": null} +{"command": "powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File C:\\one-tests\\read-current.ps1 -Root C:\\one-tests\\runs\\capture -CloneHost ONE-M6-8C0AB998 -ExpectedPages 4 -UseCurrentCache -KeepOpen", "exit": 0, "stdout": "Read 4 sections and 4 pages.\r\n", "stderr": "", "error": null} {"command": "powershell -NoProfile -Command \"Compress-Archive -Force -Path C:\\one-tests\\runs\\capture\\* -DestinationPath C:\\one-tests\\captured.zip\"", "exit": 0, "stdout": "", "stderr": "", "error": null} diff --git a/corpus/styles/cold/machine.json b/corpus/styles/cold/machine.json index d9ad4f5236be591af98c703770701c5faaa9c69f..769ecc316329ee7fa704e28331d07f2ab33daa32 100644 --- a/corpus/styles/cold/machine.json +++ b/corpus/styles/cold/machine.json @@ -1 +1 @@ -{"name": "m6-f5fcf7ca", "hostname": "ONE-M6-F5FCF7CA"} +{"name": "m6-8c0ab998", "hostname": "ONE-M6-8C0AB998"} diff --git a/corpus/styles/cold/notebook/Editorial.one b/corpus/styles/cold/notebook/Editorial.one index 42f857451ba8abf0e81045c2d3b628320494a51f..27b693af1dfba21329512bab29e9ea8b7d8ad2bb 100644 Binary files a/corpus/styles/cold/notebook/Editorial.one and b/corpus/styles/cold/notebook/Editorial.one differ diff --git a/corpus/styles/cold/notebook/Manuscript.one b/corpus/styles/cold/notebook/Manuscript.one index 6d1f3cd16fe92799c184c6678aa689fc3a8f62d7..5fb3c791e4a9e3253a4b0f77d4f9204db99d0d50 100644 Binary files a/corpus/styles/cold/notebook/Manuscript.one and b/corpus/styles/cold/notebook/Manuscript.one differ diff --git a/corpus/styles/cold/notebook/Modern.one b/corpus/styles/cold/notebook/Modern.one index e3fe52ba72f439b9e62363cfe795e4e01414aff9..779c9408a3b068d870754bf0d5f9a9861e29963c 100644 Binary files a/corpus/styles/cold/notebook/Modern.one and b/corpus/styles/cold/notebook/Modern.one differ diff --git a/corpus/styles/cold/notebook/OneNote.one b/corpus/styles/cold/notebook/OneNote.one index f0d94cc4502a0c7ce214f7d3c5ff2016dc6244e1..51e5564f999a59a8c258f16ec623d0e86b168a09 100644 Binary files a/corpus/styles/cold/notebook/OneNote.one and b/corpus/styles/cold/notebook/OneNote.one differ diff --git a/corpus/styles/cold/notebook/Open Notebook.onetoc2 b/corpus/styles/cold/notebook/Open Notebook.onetoc2 index 173f9614ad2806f275337099312ee2669cf591ad..ca525786036d48e0583208a71b5ba74a644a3887 100644 Binary files a/corpus/styles/cold/notebook/Open Notebook.onetoc2 and b/corpus/styles/cold/notebook/Open Notebook.onetoc2 differ diff --git a/corpus/styles/cold/read/environment.json b/corpus/styles/cold/read/environment.json index bcacd47aaab9e1d7dc2ea05d8c2181a0d19883cf..d5016a62c106e32794b8cb996f8b72181fa79527 100644 --- a/corpus/styles/cold/read/environment.json +++ b/corpus/styles/cold/read/environment.json @@ -1,7 +1,7 @@ { "powershell": "5.1.14409.1005", "schema": "xs2010", - "hostname": "ONE-M6-F5FCF7CA", + "hostname": "ONE-M6-8C0AB998", "cold": false, "onenote": "14.0.4763.1000" } diff --git a/corpus/styles/cold/read/hierarchy.xml b/corpus/styles/cold/read/hierarchy.xml index 2e84ba8ccaf5c8bc608567fac40c07bd120cc051..ada4dd30bb41a573d317ebd3470d2616034a9d05 100644 --- a/corpus/styles/cold/read/hierarchy.xml +++ b/corpus/styles/cold/read/hierarchy.xml @@ -1,2 +1,2 @@  - + diff --git a/corpus/styles/cold/read/page-000.navigation.json b/corpus/styles/cold/read/page-000.navigation.json index eb3009ecdd53b4c3f537147cba67b7f35fb93b77..fbef07913da8ee5d5dac2283fcacb7e449ba65d5 100644 --- a/corpus/styles/cold/read/page-000.navigation.json +++ b/corpus/styles/cold/read/page-000.navigation.json @@ -6,7 +6,7 @@ "h": 600, "error": null, "win": { - "title": "Heading 1 in OneNote - Microsoft OneNote", + "title": "Heading 1 in Modern - Microsoft OneNote", "class": "Framework::CFrame", "dialog": false } diff --git a/corpus/styles/cold/read/page-000.png b/corpus/styles/cold/read/page-000.png index f0054128fc722539634e17b44dce82dca4a2b9e9..fe19adce741e94ca710acf8ddb88bd583b0724ad 100644 Binary files a/corpus/styles/cold/read/page-000.png and b/corpus/styles/cold/read/page-000.png differ diff --git a/corpus/styles/cold/read/page-000.xml b/corpus/styles/cold/read/page-000.xml index c23fa4941ab433dbb201a60b7632820b5dafeca8..69fe1d88b40a660af0ccbc689c456663135aa14e 100644 --- a/corpus/styles/cold/read/page-000.xml +++ b/corpus/styles/cold/read/page-000.xml @@ -1,8 +1,9 @@  -Heading 1 in OneNote]]>Heading 2 in OneNote]]>Heading 3 in OneNote]]>Heading 4 in OneNote]]>Heading 6 in OneNote]]>Quote in OneNote]]> +Heading 1 in Modern]]>Heading 2 in Modern]]>Heading 3 in Modern]]>Heading 4 in Modern]]>Heading 5 in Modern]]>Heading 6 in Modern]]>Quote in Modern]]> diff --git a/corpus/styles/cold/read/page-001.navigation.json b/corpus/styles/cold/read/page-001.navigation.json index fbef07913da8ee5d5dac2283fcacb7e449ba65d5..eb3009ecdd53b4c3f537147cba67b7f35fb93b77 100644 --- a/corpus/styles/cold/read/page-001.navigation.json +++ b/corpus/styles/cold/read/page-001.navigation.json @@ -6,7 +6,7 @@ "h": 600, "error": null, "win": { - "title": "Heading 1 in Modern - Microsoft OneNote", + "title": "Heading 1 in OneNote - Microsoft OneNote", "class": "Framework::CFrame", "dialog": false } diff --git a/corpus/styles/cold/read/page-001.png b/corpus/styles/cold/read/page-001.png index 52782aac431eb65ef6fa40043f7bd444cc753297..6e0d15cf578062543ba583b72474a77bad3a5c73 100644 Binary files a/corpus/styles/cold/read/page-001.png and b/corpus/styles/cold/read/page-001.png differ diff --git a/corpus/styles/cold/read/page-001.xml b/corpus/styles/cold/read/page-001.xml index 59154708f7de31d84f9bfc0d91e18e68ab1e4c4d..99a3dcd5d8164e42161a36fffbfd5c135254d444 100644 --- a/corpus/styles/cold/read/page-001.xml +++ b/corpus/styles/cold/read/page-001.xml @@ -1,9 +1,8 @@  -Heading 1 in Modern]]>Heading 2 in Modern]]>Heading 3 in Modern]]>Heading 4 in Modern]]>Heading 5 in Modern]]>Heading 6 in Modern]]>Quote in Modern]]> +Heading 1 in OneNote]]>Heading 2 in OneNote]]>Heading 3 in OneNote]]>Heading 4 in OneNote]]>Heading 6 in OneNote]]>Quote in OneNote]]> diff --git a/corpus/styles/cold/read/page-002.png b/corpus/styles/cold/read/page-002.png index 0f5ff46430e34aa7971d9584457be80632a4bdf8..4f504444c08ea13d8e82dd4e34ee970eefcbc336 100644 Binary files a/corpus/styles/cold/read/page-002.png and b/corpus/styles/cold/read/page-002.png differ diff --git a/corpus/styles/cold/read/page-002.xml b/corpus/styles/cold/read/page-002.xml index 7ed0b85e7bff9253474475955ecf43d03ea4501e..70e92807c489d392660e37911e250731999acb52 100644 --- a/corpus/styles/cold/read/page-002.xml +++ b/corpus/styles/cold/read/page-002.xml @@ -1,8 +1,8 @@  -Heading 1 in Editorial]]>Heading 2 in Editorial]]>Heading 3 in Editorial]]>Heading 4 in Editorial]]>Heading 6 in Editorial]]>Quote in Editorial]]> +Heading 1 in Editorial]]>Heading 2 in Editorial]]>Heading 3 in Editorial]]>Heading 4 in Editorial]]>Heading 6 in Editorial]]>Quote in Editorial]]> diff --git a/corpus/styles/cold/read/page-003.png b/corpus/styles/cold/read/page-003.png index ed25a5304fec32984cfccceffdeecfb3d0bb35a6..42e54a261a13730563bbf1e43aafce568f7fcfc1 100644 Binary files a/corpus/styles/cold/read/page-003.png and b/corpus/styles/cold/read/page-003.png differ diff --git a/corpus/styles/cold/read/page-003.xml b/corpus/styles/cold/read/page-003.xml index af3bcc55a623d5a9f6c81dbf9abf271be2f75db6..d3d3dfc8ee79e213c58253d5cb02d41c15ac805b 100644 --- a/corpus/styles/cold/read/page-003.xml +++ b/corpus/styles/cold/read/page-003.xml @@ -1,7 +1,7 @@  -Heading 2 in Manuscript]]>Heading 3 in Manuscript]]>Heading 4 in Manuscript]]>Heading 6 in Manuscript]]>Quote in Manuscript]]> +Heading 2 in Manuscript]]>Heading 3 in Manuscript]]>Heading 4 in Manuscript]]>Heading 6 in Manuscript]]>Quote in Manuscript]]> diff --git a/corpus/styles/cold/run.json b/corpus/styles/cold/run.json index ef5eb72df7edda326be0f35ce40f2e7ce099e1bc..dc3c95dbb72eef993864378a640873bc37c7d999 100644 --- a/corpus/styles/cold/run.json +++ b/corpus/styles/cold/run.json @@ -1,7 +1,7 @@ { - "notebook": "/private/var/folders/90/4f4rngds01j55ggdj_vglk_c0000gn/T/styles-export", + "notebook": "/private/var/folders/90/4f4rngds01j55ggdj_vglk_c0000gn/T/styles-export4", "expected_pages": 4, - "author": "/Users/clo/dev/one-styles-review/tools/native/styles.ps1", + "author": "/Users/clo/dev/one-styles-polish2/tools/native/styles.ps1", "author_timeout_seconds": 600, "inspect": false, "collect_notebook": true, diff --git a/corpus/styles/cold/source.json b/corpus/styles/cold/source.json index 4dbea11f7f6a2a93629a4acd850414502f94cecf..1a5e191dcb2b67e8b7c667a66ef6993f7fcd6977 100644 --- a/corpus/styles/cold/source.json +++ b/corpus/styles/cold/source.json @@ -2,37 +2,37 @@ { "path": ".snowbound/themes.json", "bytes": 671, - "sha256": "d6b191076a9f833cb3e79a38121ed9d1fe29a405a79138969fb88b0b43066594", - "mtime_ns": 1790988700942364730 + "sha256": "934939799ca2f53c4aced72499c2748fcd7687e30b565092d2de2800caaaa5f8", + "mtime_ns": 1791020507572485805 }, { "path": "Editorial.one", "bytes": 12096, - "sha256": "79f3d171ad78db53de276119c81f2fe4b6e298a6554494f407cd74436d43ecec", - "mtime_ns": 1790988700940784899 + "sha256": "1910fb64ad1b3f23e6bf0b5580ccd043e144e3c92ac57d285d40b1626ac77a10", + "mtime_ns": 1791020507569024773 }, { "path": "Manuscript.one", "bytes": 12120, - "sha256": "f4d25c78ed8537f486afa7e4e1853f9816895dc5d794c598248de649fac851ef", - "mtime_ns": 1790988700940457857 + "sha256": "d382852a1bacb01c2e69fef9209f1c74fe0e06f7514bb7ff75e1cdb659b5ab93", + "mtime_ns": 1791020507567998484 }, { "path": "Modern.one", "bytes": 12000, - "sha256": "a91513231304e0a27e6896cf374cff98ddc4528a479622f0cbfb7577da151986", - "mtime_ns": 1790988700941597439 + "sha256": "5f9abd7de149ec6bdebcaaabf51bfb165cc5a8f356112465579cc8a511e4e60a", + "mtime_ns": 1791020507569971062 }, { "path": "OneNote.one", "bytes": 12072, - "sha256": "1f84914801b00eb77a201c148146afc5e2544c207528710d70937833750ab300", - "mtime_ns": 1790988700941853856 + "sha256": "5a84202c772092e219edd88949a780de090bec274a38a28a56865f5c725a1aa9", + "mtime_ns": 1791020507571414767 }, { "path": "Open Notebook.onetoc2", "bytes": 2036, - "sha256": "a89533b7656fd9f5db22dadec54550a520b1b77980aad8398a7f3126f82b9d00", - "mtime_ns": 1790988700941091815 + "sha256": "78d1b9ff6c1b7137835112aac7f8d7d80628836c3d7b5641f343b1319e008a29", + "mtime_ns": 1791020507569552022 } ] diff --git a/crates/notebook/src/sidecar/themes.rs b/crates/notebook/src/sidecar/themes.rs index 5d93db7125914171107fd00a915b6c78a8005e5d..60455ac0ffae15607c244649e6331714cfd637a3 100644 --- a/crates/notebook/src/sidecar/themes.rs +++ b/crates/notebook/src/sidecar/themes.rs @@ -356,18 +356,27 @@ const BOTH: [bool; 2] = [true, true]; const NONE: [f32; 2] = [0.0; 2]; /// The theme new notebooks take unless the user chooses another. -pub const DEFAULT: &str = "modern-2"; +pub const DEFAULT: &str = "modern-3"; -/// Built-ins a page wears still but no longer offered: a changed look ships under a new id. -const RETIRED: [&str; 1] = ["modern"]; +/// Built-ins a page wears still but no longer offered, each with the one offered in its +/// place: a changed look ships under a new id. +const RETIRED: [(&str, &str); 2] = [("modern", "modern-3"), ("modern-2", "modern-3")]; /// The themes Snowbound offers, OneNote 2010's first. pub fn built_in() -> Vec { let mut offered = shipped(); - offered.retain(|theme| !RETIRED.contains(&theme.id.as_str())); + offered.retain(|theme| RETIRED.iter().all(|(retired, _)| theme.id != *retired)); offered } +/// The built-in offered in place of theme `id`, as a choice kept for later takes it; `id` +/// where it isn't retired. +pub fn successor(id: &str) -> &str { + (RETIRED.iter()) + .find(|(retired, _)| *retired == id) + .map_or(id, |(_, successor)| successor) +} + /// Every theme Snowbound ever shipped. Once shipped a built-in's look never changes: two /// versions disagreeing would restyle a page back and forth as each opens it. fn shipped() -> Vec { @@ -441,10 +450,27 @@ fn shipped() -> Vec { style("Calibri", 11.5, PLAIN, Some("#262626"), [0.0, 3.0]), ], ), - // OneNote's page title in Arial; its accent the section's. + // OneNote's page title in Arial, its text automatic but for the section's accent. theme( - "modern-2", + "modern-3", "Modern", + [ + tinted(style("Arial", 16.0, BOLD, None, [10.0, 2.0])), + style("Arial", 13.0, BOLD, None, [8.0, 2.0]), + style("Arial", 11.0, BOLD, None, [6.0, 0.0]), + style("Arial", 10.5, BOTH, None, [6.0, 0.0]), + tinted(style("Arial", 10.5, BOLD, None, [6.0, 0.0])), + tinted(style("Arial", 10.5, ITALIC, None, [6.0, 0.0])), + style("Arial", 17.0, PLAIN, None, NONE), + style("Arial", 8.0, PLAIN, None, NONE), + style("Arial", 10.5, ITALIC, None, [0.0, 3.0]), + style("Courier New", 10.0, PLAIN, None, NONE), + style("Arial", 10.5, PLAIN, None, [0.0, 3.0]), + ], + ), + theme( + "modern-2", + "Modern (coloured text)", [ tinted(style("Arial", 16.0, BOLD, None, [10.0, 2.0])), style("Arial", 13.0, BOLD, Some("#1B2631"), [8.0, 2.0]), @@ -584,17 +610,30 @@ mod tests { assert_eq!(json["accent"], true); } - /// Modern's title is OneNote's in Arial. The Modern first shipped, its title bold, is - /// no longer offered, but pages given it keep it. + /// Modern's title is OneNote's in Arial, and its text automatic but for the accent. The Moderns shipped + /// before are no longer offered, but pages given them keep them, and a default kept for + /// new notebooks moves on. #[test] fn modern_keeps_onenote_s_page_title_and_the_first_modern_stays() { - let [onenote, modern] = ["onenote", "modern-2"] + let [onenote, modern] = ["onenote", "modern-3"] .map(|id| built_in().into_iter().find(|theme| theme.id == id).unwrap()); let title = |theme: &Theme| definition("PageTitle", &theme.styles["PageTitle"], None); let mut expected = title(&onenote); expected.format.font = Some("Arial".into()); assert_eq!(title(&modern), expected); + for (name, style) in &modern.styles { + let accent = matches!(name.as_str(), "h1" | "h5" | "h6"); + assert_eq!(style.accent, accent, "{name}"); + assert_eq!(style.colorref(None).is_none(), !accent, "{name}"); + } + assert!( + built_in() + .iter() + .all(|theme| !theme.id.starts_with("modern-2")) + ); assert!(built_in().iter().all(|theme| theme.id != "modern")); + assert_eq!(successor("modern-2"), DEFAULT); + assert_eq!(successor("editorial"), "editorial"); let themes = Themes { assignments: vec![Assignment { scope: Scope::Notebook, diff --git a/crates/snowbound/src/main.rs b/crates/snowbound/src/main.rs index e625cc549a14b556fe701d5ee97368bbef18e445..502348d35f1be2894533b7ed27207d87637b72b6 100644 --- a/crates/snowbound/src/main.rs +++ b/crates/snowbound/src/main.rs @@ -1259,7 +1259,8 @@ impl State { locked, password: None, passwords: stored.passwords, - notebook_theme: stored.notebook_theme.0, + notebook_theme: (stored.notebook_theme.0) + .map(|id| notebook::sidecar::themes::successor(&id).to_owned()), live_options: stored.live, drag: None, templates: templates::View::Strip, diff --git a/tools/test_styles.py b/tools/test_styles.py index 64ea381929e7678b3ef6c2d9ffccd79d49ad3024..201466033b98f0f161b506cadf094e8227b49288 100644 --- a/tools/test_styles.py +++ b/tools/test_styles.py @@ -45,8 +45,10 @@ class StylesTest(unittest.TestCase): self.assertEqual(set(defined), GALLERY, theme) self.assertEqual(defined['h1'], [heading[theme]], theme) if theme == 'Modern': - # OneNote's own page title, in Arial. + # OneNote's own page title, in Arial, and text automatic but for the accent. self.assertEqual(defined['PageTitle'], [('Arial', 17.0, False, 'automatic')]) + self.assertEqual(defined['p'], [('Arial', 10.5, False, 'automatic')]) + self.assertEqual(defined['h2'], [('Arial', 13.0, True, 'automatic')]) self.assertEqual(seen, set(heading)) def test_onenote_s_own_styles_read_under_the_same_names(self):