diff --git a/Cargo.lock b/Cargo.lock index 09e63cbb3d..f9288c9eb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4682,9 +4682,9 @@ dependencies = [ [[package]] name = "markup_fmt" -version = "0.16.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f303c36143671ac6c54112eb5aa95649b169dae783fdb6ead2c0e88b408c425c" +checksum = "fa7605bb4ad755a9ab5c96f2ce3bfd4eb8acd559b842c041fc8a5f84d63aed3a" dependencies = [ "aho-corasick", "css_dataset", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 728f6726b5..2012c90dfb 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -130,7 +130,7 @@ libz-sys.workspace = true log = { workspace = true, features = ["serde"] } lsp-types.workspace = true malva = "=0.11.0" -markup_fmt = "=0.16.0" +markup_fmt = "=0.18.0" memmem.workspace = true monch.workspace = true notify.workspace = true diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index c2c2a6bb6b..e29627345c 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -440,8 +440,10 @@ pub fn format_html( ) } _ => { - let mut typescript_config = - get_resolved_typescript_config(fmt_options); + let mut typescript_config_builder = + get_typescript_config_builder(fmt_options); + typescript_config_builder.file_indent_level(hints.indent_level); + let mut typescript_config = typescript_config_builder.build(); typescript_config.line_width = hints.print_width as u32; dprint_plugin_typescript::format_text( &path, @@ -919,9 +921,9 @@ fn files_str(len: usize) -> &'static str { } } -fn get_resolved_typescript_config( +fn get_typescript_config_builder( options: &FmtOptionsConfig, -) -> dprint_plugin_typescript::configuration::Configuration { +) -> dprint_plugin_typescript::configuration::ConfigurationBuilder { let mut builder = dprint_plugin_typescript::configuration::ConfigurationBuilder::new(); builder.deno(); @@ -953,7 +955,13 @@ fn get_resolved_typescript_config( }); } - builder.build() + builder +} + +fn get_resolved_typescript_config( + options: &FmtOptionsConfig, +) -> dprint_plugin_typescript::configuration::Configuration { + get_typescript_config_builder(options).build() } fn get_resolved_markdown_config( @@ -1075,6 +1083,7 @@ fn get_resolved_markup_fmt_config( }; let language_options = LanguageOptions { + script_formatter: Some(markup_fmt::config::ScriptFormatter::Dprint), quotes: Quotes::Double, format_comments: false, script_indent: true, diff --git a/tests/specs/fmt/html/__test__.jsonc b/tests/specs/fmt/html/__test__.jsonc index 2e6d08d4cc..96b7f4ed92 100644 --- a/tests/specs/fmt/html/__test__.jsonc +++ b/tests/specs/fmt/html/__test__.jsonc @@ -12,6 +12,10 @@ "broken": { "args": "fmt broken.html", "output": "broken.out" + }, + "with_js": { + "args": "fmt --check with_js.html", + "output": "Checked 1 file\n" } } } diff --git a/tests/specs/fmt/html/with_js.html b/tests/specs/fmt/html/with_js.html new file mode 100644 index 0000000000..d956c6728b --- /dev/null +++ b/tests/specs/fmt/html/with_js.html @@ -0,0 +1,9 @@ + + + + +