diff --git a/config-file-schema.json b/config-file-schema.json index 330b0d49..3ec2887c 100644 --- a/config-file-schema.json +++ b/config-file-schema.json @@ -536,6 +536,13 @@ "MermaidConfig": { "type": "object", "properties": { + "config_path": { + "description": "A path to a mermaid JSON configuration file to be used by the `mmdc` tool.", + "type": [ + "string", + "null" + ] + }, "pupeteer_config_path": { "description": "A path to a pupeteer JSON configuration file to be used by the `mmdc` tool.", "type": [ diff --git a/src/config.rs b/src/config.rs index 227b91f9..44ff4c0f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -341,11 +341,14 @@ pub struct MermaidConfig { /// A path to a pupeteer JSON configuration file to be used by the `mmdc` tool. pub pupeteer_config_path: Option, + + /// A path to a mermaid JSON configuration file to be used by the `mmdc` tool. + pub config_path: Option, } impl Default for MermaidConfig { fn default() -> Self { - Self { scale: default_mermaid_scale(), pupeteer_config_path: None } + Self { scale: default_mermaid_scale(), pupeteer_config_path: None, config_path: None } } } diff --git a/src/main.rs b/src/main.rs index a38ad7a8..db2ec104 100644 --- a/src/main.rs +++ b/src/main.rs @@ -255,6 +255,7 @@ impl CoreComponents { typst_ppi: config.typst.ppi.to_string(), mermaid_scale: config.mermaid.scale.to_string(), mermaid_pupeteer_file: config.mermaid.pupeteer_config_path.clone(), + mermaid_config_file: config.mermaid.config_path.clone(), d2_scale: config.d2.scale.map(|s| s.to_string()).unwrap_or_else(|| "-1".to_string()), threads: config.snippet.render.threads, }; diff --git a/src/third_party.rs b/src/third_party.rs index 1af21dc1..ab23011a 100644 --- a/src/third_party.rs +++ b/src/third_party.rs @@ -32,6 +32,7 @@ pub struct ThirdPartyConfigs { pub typst_ppi: String, pub mermaid_scale: String, pub mermaid_pupeteer_file: Option, + pub mermaid_config_file: Option, pub d2_scale: String, pub threads: usize, } @@ -69,6 +70,7 @@ impl Default for ThirdPartyRender { typst_ppi: default_typst_ppi().to_string(), mermaid_scale: default_mermaid_scale().to_string(), mermaid_pupeteer_file: None, + mermaid_config_file: None, d2_scale: "-1".to_string(), threads: default_snippet_render_threads(), }; @@ -213,8 +215,11 @@ impl Worker { "-b", &style.background, ]; - if let Some(pupeteer_config_path) = &self.shared.config.mermaid_pupeteer_file { - args.extend(&["-p", pupeteer_config_path]); + if let Some(path) = &self.shared.config.mermaid_pupeteer_file { + args.extend(&["-p", path]); + } + if let Some(path) = &self.shared.config.mermaid_config_file { + args.extend(&["-c", path]); } ThirdPartyTools::mermaid(&args).run()?;