Skip to content

Commit c46c232

Browse files
committed
feat: allow passing in a mermaid config file
1 parent 35f4a08 commit c46c232

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,14 @@ pub struct MermaidConfig {
341341

342342
/// A path to a pupeteer JSON configuration file to be used by the `mmdc` tool.
343343
pub pupeteer_config_path: Option<String>,
344+
345+
/// A path to a mermaid JSON configuration file to be used by the `mmdc` tool.
346+
pub config_path: Option<String>,
344347
}
345348

346349
impl Default for MermaidConfig {
347350
fn default() -> Self {
348-
Self { scale: default_mermaid_scale(), pupeteer_config_path: None }
351+
Self { scale: default_mermaid_scale(), pupeteer_config_path: None, config_path: None }
349352
}
350353
}
351354

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ impl CoreComponents {
255255
typst_ppi: config.typst.ppi.to_string(),
256256
mermaid_scale: config.mermaid.scale.to_string(),
257257
mermaid_pupeteer_file: config.mermaid.pupeteer_config_path.clone(),
258+
mermaid_config_file: config.mermaid.config_path.clone(),
258259
d2_scale: config.d2.scale.map(|s| s.to_string()).unwrap_or_else(|| "-1".to_string()),
259260
threads: config.snippet.render.threads,
260261
};

src/third_party.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub struct ThirdPartyConfigs {
3232
pub typst_ppi: String,
3333
pub mermaid_scale: String,
3434
pub mermaid_pupeteer_file: Option<String>,
35+
pub mermaid_config_file: Option<String>,
3536
pub d2_scale: String,
3637
pub threads: usize,
3738
}
@@ -69,6 +70,7 @@ impl Default for ThirdPartyRender {
6970
typst_ppi: default_typst_ppi().to_string(),
7071
mermaid_scale: default_mermaid_scale().to_string(),
7172
mermaid_pupeteer_file: None,
73+
mermaid_config_file: None,
7274
d2_scale: "-1".to_string(),
7375
threads: default_snippet_render_threads(),
7476
};
@@ -213,8 +215,11 @@ impl Worker {
213215
"-b",
214216
&style.background,
215217
];
216-
if let Some(pupeteer_config_path) = &self.shared.config.mermaid_pupeteer_file {
217-
args.extend(&["-p", pupeteer_config_path]);
218+
if let Some(path) = &self.shared.config.mermaid_pupeteer_file {
219+
args.extend(&["-p", path]);
220+
}
221+
if let Some(path) = &self.shared.config.mermaid_config_file {
222+
args.extend(&["-c", path]);
218223
}
219224

220225
ThirdPartyTools::mermaid(&args).run()?;

0 commit comments

Comments
 (0)