From 459eb6c0dba15f5c4590edc2df74dba8352a31a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 03:03:25 +0000 Subject: [PATCH 1/3] build(deps): bump the minor-changes group across 1 directory with 2 updates Bumps the minor-changes group with 2 updates in the / directory: [handlebars](https://github.com/sunng87/handlebars-rust) and [serde_json](https://github.com/serde-rs/json). Updates `handlebars` from 6.4.0 to 6.4.1 - [Release notes](https://github.com/sunng87/handlebars-rust/releases) - [Changelog](https://github.com/sunng87/handlebars-rust/blob/master/CHANGELOG.md) - [Commits](https://github.com/sunng87/handlebars-rust/compare/v6.4.0...v6.4.1) Updates `serde_json` from 1.0.149 to 1.0.150 - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.149...v1.0.150) --- updated-dependencies: - dependency-name: handlebars dependency-version: 6.4.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-changes - dependency-name: serde_json dependency-version: 1.0.150 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-changes ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 315ce5be..40119e7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -430,9 +430,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "6.4.0" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3f9296c208515b87bd915a2f5d1163d4b3f863ba83337d7713cf478055948e" +checksum = "d43ccdfe15a81ab0a8af639e90254227c9a46afd9c5f5b6ec7efaa345c4b0f00" dependencies = [ "derive_builder", "log", @@ -1089,9 +1089,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", diff --git a/Cargo.toml b/Cargo.toml index 26ff4fba..801b2744 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ clap = "4.6.1" compile-fmt = "0.1.0" doc-comment = "0.3.4" font-subset = "0.1.0" -handlebars = "6.4.0" +handlebars = "6.4.1" humantime = "2.3.0" os_pipe = "1.2.3" portable-pty = "0.8.1" # FIXME: portable-pty 0.9 is seemingly broken on Windows From 748f374c0279cd13d67cd8f470ce4eb4f5919abb Mon Sep 17 00:00:00 2001 From: Alex Ostrovski Date: Wed, 3 Jun 2026 11:09:59 +0300 Subject: [PATCH 2/3] Fix partial resolution --- .../term-transcript/src/svg/common.handlebars | 6 +++ .../src/svg/default.svg.handlebars | 8 ++-- crates/term-transcript/src/svg/mod.rs | 2 +- .../src/svg/pure.svg.handlebars | 8 ++-- crates/term-transcript/src/svg/tests.rs | 44 ++++++++++++------- docs/src/assets/custom.html.handlebars | 8 +++- 6 files changed, 50 insertions(+), 26 deletions(-) diff --git a/crates/term-transcript/src/svg/common.handlebars b/crates/term-transcript/src/svg/common.handlebars index 65c07cc8..ad68610a 100644 --- a/crates/term-transcript/src/svg/common.handlebars +++ b/crates/term-transcript/src/svg/common.handlebars @@ -243,3 +243,9 @@ {{~round (mul line_height const.FONT_SIZE) digits=1~}} {{~/if~}} {{/inline~}} + +{{! + Include main rendering logic. We need this roundabout construction in order for common inlines to be available + to the format-specific rendering logic. +}} +{{~>main~}} diff --git a/crates/term-transcript/src/svg/default.svg.handlebars b/crates/term-transcript/src/svg/default.svg.handlebars index b202ce15..d1bbb1c8 100644 --- a/crates/term-transcript/src/svg/default.svg.handlebars +++ b/crates/term-transcript/src/svg/default.svg.handlebars @@ -1,6 +1,3 @@ -{{! Load common helpers }} -{{>_helpers~}} - {{! Root template }} {{~#*inline "root"}} @@ -216,7 +213,7 @@ {{/scope}} {{/inline~}} -{{! Main logic }} +{{~#*inline "main"~}} {{#scope content_height=0 scroll_animation=null @@ -254,3 +251,6 @@ {{~/if~}} {{>root (splat_vars this)~}} {{! <-- All rendering happens here }} {{/scope}} +{{~/inline~}} + +{{~>_common~}} diff --git a/crates/term-transcript/src/svg/mod.rs b/crates/term-transcript/src/svg/mod.rs index 3ad51d2d..0a33f1cd 100644 --- a/crates/term-transcript/src/svg/mod.rs +++ b/crates/term-transcript/src/svg/mod.rs @@ -327,7 +327,7 @@ impl Template { register_helpers(&mut handlebars); handlebars.register_template(MAIN_TEMPLATE_NAME, template); let helpers = HandlebarsTemplate::compile(COMMON_HELPERS).unwrap(); - handlebars.register_template("_helpers", helpers); + handlebars.register_template("_common", helpers); Self { options: options.into_inner(), handlebars, diff --git a/crates/term-transcript/src/svg/pure.svg.handlebars b/crates/term-transcript/src/svg/pure.svg.handlebars index 8f239a8a..87cdc0e0 100644 --- a/crates/term-transcript/src/svg/pure.svg.handlebars +++ b/crates/term-transcript/src/svg/pure.svg.handlebars @@ -1,6 +1,3 @@ -{{! Load common helpers }} -{{>_helpers~}} - {{! Renders `class` and/or `style` attributes for a background SVG span }} {{~#*inline "svg_bg_tspan_attrs"}} {{~#scope bg=bg classes="" styles=""}} @@ -317,7 +314,7 @@ {{~/scope~}} {{~/inline~}} -{{! Main logic }} +{{~#*inline "main"~}} {{#scope content_height=0 scroll_animation=null @@ -392,3 +389,6 @@ {{~/if~}} {{>root (splat_vars this)~}} {{! <-- All rendering happens here }} {{/scope}} +{{~/inline~}} + +{{~>_common~}} diff --git a/crates/term-transcript/src/svg/tests.rs b/crates/term-transcript/src/svg/tests.rs index f83f6c74..540fe6e7 100644 --- a/crates/term-transcript/src/svg/tests.rs +++ b/crates/term-transcript/src/svg/tests.rs @@ -1011,6 +1011,12 @@ fn embedding_font(pure_svg: bool, with_line_numbers: bool) { } } +const HTML_SPAN_TEMPLATE: &str = r#" + {{~#>_helpers~}} + {{~#*inline "main"~}}{{>html_span}}{{~/inline~}} + {{~/_helpers~}} +"#; + #[test] fn rendering_html_span() { let helpers = HandlebarsTemplate::compile(COMMON_HELPERS).unwrap(); @@ -1022,7 +1028,7 @@ fn rendering_html_span() { text: "Test", }); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, "Test"); @@ -1038,7 +1044,7 @@ fn rendering_html_span() { text: "Test", }); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!( rendered, @@ -1052,7 +1058,7 @@ fn rendering_html_span() { text: "Test", }); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, "Test"); } @@ -1072,19 +1078,19 @@ fn rendering_inverted_html_span() { text: "Test", }; let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, r#"Test"#); data.style.fg = Some(SerdeColor::Index(5)); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, r#"Test"#); data.style.bg = Some(SerdeColor::Rgb(RgbColor(0xc0, 0xff, 0xee))); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!( rendered, @@ -1108,7 +1114,7 @@ fn rendering_blinking_html_span() { text: "Test", }; let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!( rendered, @@ -1132,7 +1138,7 @@ fn rendering_dimmed_html_span() { text: "Test", }; let rendered = handlebars - .render_template("{{>_helpers}}\n{{>html_span}}", &data) + .render_template(HTML_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!( rendered, @@ -1140,6 +1146,14 @@ fn rendering_dimmed_html_span() { ); } +const SVG_SPAN_TEMPLATE: &str = r#" + {{~#>_helpers~}} + {{~#*inline "main"~}} + {{>svg_tspan_attrs}} + {{~/inline~}} + {{~/_helpers~}} +"#; + #[test] fn rendering_svg_tspan() { let helpers = HandlebarsTemplate::compile(COMMON_HELPERS).unwrap(); @@ -1151,7 +1165,7 @@ fn rendering_svg_tspan() { text: "Test", }); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>svg_tspan_attrs}}", &data) + .render_template(SVG_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, ""); @@ -1167,7 +1181,7 @@ fn rendering_svg_tspan() { text: "Test", }); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>svg_tspan_attrs}}", &data) + .render_template(SVG_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, " class=\"bold underline fg2 bg#cfc\""); @@ -1179,7 +1193,7 @@ fn rendering_svg_tspan() { text: "Test", }); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>svg_tspan_attrs}}", &data) + .render_template(SVG_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, " class=\"bold dimmed fg2 bg0\""); @@ -1191,7 +1205,7 @@ fn rendering_svg_tspan() { text: "Test", }); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>svg_tspan_attrs}}", &data) + .render_template(SVG_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, " class=\"bold\" style=\"fill: #c0ffee;\""); } @@ -1211,19 +1225,19 @@ fn rendering_inverted_svg_tspan() { text: "Test", }; let rendered = handlebars - .render_template("{{>_helpers}}\n{{>svg_tspan_attrs}}", &data) + .render_template(SVG_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, r#" class="inv fg-none bg-none""#); data.style.fg = Some(SerdeColor::Index(5)); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>svg_tspan_attrs}}", &data) + .render_template(SVG_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, r#" class="inv fg-none bg5""#); data.style.bg = Some(SerdeColor::Rgb(RgbColor(0xc0, 0xff, 0xee))); let rendered = handlebars - .render_template("{{>_helpers}}\n{{>svg_tspan_attrs}}", &data) + .render_template(SVG_SPAN_TEMPLATE, &data) .unwrap(); assert_eq!(rendered, r#" class="inv bg5" style="fill: #c0ffee;""#); } diff --git a/docs/src/assets/custom.html.handlebars b/docs/src/assets/custom.html.handlebars index 6ba86b5f..2cae8e85 100644 --- a/docs/src/assets/custom.html.handlebars +++ b/docs/src/assets/custom.html.handlebars @@ -2,8 +2,7 @@ Example of a custom Handlebars template for use with `term-transcript`. This template renders an HTML document with collapsible interaction sections. }} -{{! Import misc helpers to the scope. }} -{{>_helpers}} + {{! CSS definitions: colors. }} {{~#*inline "styles_colors"}} :root { @@ -77,6 +76,7 @@ {{/inline~}} +{{~#*inline "main"}} @@ -130,3 +130,7 @@ +{{~/inline~}} + +{{! Import the main template which will automatically pick up the `main` partial defined above. }} +{{>_common}} From d86f669866c3e489a1843bdc2ab020ace0e0ff7e Mon Sep 17 00:00:00 2001 From: Alex Ostrovski Date: Wed, 3 Jun 2026 12:22:34 +0300 Subject: [PATCH 3/3] Fix whitespace control for custom template --- docs/src/assets/custom.html.handlebars | 7 +++---- e2e-tests/rainbow/tests/integration.rs | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/src/assets/custom.html.handlebars b/docs/src/assets/custom.html.handlebars index 2cae8e85..5b5c228b 100644 --- a/docs/src/assets/custom.html.handlebars +++ b/docs/src/assets/custom.html.handlebars @@ -2,7 +2,6 @@ Example of a custom Handlebars template for use with `term-transcript`. This template renders an HTML document with collapsible interaction sections. }} - {{! CSS definitions: colors. }} {{~#*inline "styles_colors"}} :root { @@ -76,7 +75,7 @@ {{/inline~}} -{{~#*inline "main"}} +{{~#*inline "main"~}} @@ -130,7 +129,7 @@ -{{~/inline~}} +{{/inline~}} {{! Import the main template which will automatically pick up the `main` partial defined above. }} -{{>_common}} +{{~>_common~}} diff --git a/e2e-tests/rainbow/tests/integration.rs b/e2e-tests/rainbow/tests/integration.rs index d05f63c2..07d67475 100644 --- a/e2e-tests/rainbow/tests/integration.rs +++ b/e2e-tests/rainbow/tests/integration.rs @@ -124,6 +124,10 @@ fn snapshot_with_custom_template() -> anyhow::Result<()> { Template::custom(template, template_options.validated()?).render(&transcript, &mut buffer)?; let buffer = String::from_utf8(buffer)?; assert!(buffer.starts_with(""), "{buffer}"); + assert!( + buffer.ends_with('\n') && !buffer.ends_with("\n\n"), + "{buffer}<>" + ); Ok(()) }