From ff2950d5a341771c54c6eb1f0d9f685149651855 Mon Sep 17 00:00:00 2001 From: nilsk Date: Mon, 30 Jun 2025 21:12:21 +0200 Subject: [PATCH 1/2] added include_slide_comment parameter to the `ParserConfig` to control if it is included in the md or not --- README.md | 17 +++++++++-------- examples/basic_usage.rs | 1 + src/parser_config.rs | 11 +++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c82c7ac..b01a328 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ fn main() -> Result<(), Box> { .quality(80) .image_handling_mode(ImageHandlingMode::InMarkdown) .image_output_path(None) + .include_slide_comment(true) .build(); // alternatively use `let config = ParserConfig::default();` @@ -74,14 +75,14 @@ fn main() -> Result<(), Box> { ## Config Parameters -| Parameter | Type | Default | Description | -|------------------------|-----------------------|---------------|-----------------------------------------------------------------------------------------------------------| -| `extract_images` | `bool` | `true` | Whether images are extracted from slides or not. If false, images can not be extracted manually either. | -| `compress_images` | `bool` | `true` | Whether images are compressed before encoding or not. Effects manually extracted images too. | -| `image_quality` | `u8` | `80` | Defines the image compression quality `(0-100)`. Higher values mean better quality but larger file sizes. | -| `image_handling_mode` | `ImageHandlingMode` | `InMarkdown` | Determines how images are handled during content export | -| `image_output_path` | `Option` | `None` | Output directory path for `ImageHandlingMode::Save` (mandatory for saving mode) | - +| Parameter | Type | Default | Description | +|--------------------------|-----------------------|---------------|-----------------------------------------------------------------------------------------------------------| +| `extract_images` | `bool` | `true` | Whether images are extracted from slides or not. If false, images can not be extracted manually either. | +| `compress_images` | `bool` | `true` | Whether images are compressed before encoding or not. Effects manually extracted images too. | +| `image_quality` | `u8` | `80` | Defines the image compression quality `(0-100)`. Higher values mean better quality but larger file sizes. | +| `image_handling_mode` | `ImageHandlingMode` | `InMarkdown` | Determines how images are handled during content export | +| `image_output_path` | `Option` | `None` | Output directory path for `ImageHandlingMode::Save` (mandatory for saving mode) | +| `include_slide_comment` | `bool` | `true` | Weather the slide number comment is included or not (``) |
#### Member of `ImageHandlingMode` diff --git a/examples/basic_usage.rs b/examples/basic_usage.rs index 903c4ee..b749e9d 100644 --- a/examples/basic_usage.rs +++ b/examples/basic_usage.rs @@ -28,6 +28,7 @@ fn main() -> Result<()> { .compress_images(true) .quality(75) .image_handling_mode(ImageHandlingMode::InMarkdown) + .include_slide_comment(true) .build(); // Open the PPTX file diff --git a/src/parser_config.rs b/src/parser_config.rs index 21b95c9..19d2371 100644 --- a/src/parser_config.rs +++ b/src/parser_config.rs @@ -30,6 +30,7 @@ pub enum ImageHandlingMode { /// | `image_quality` | `u8` | `80` | Compression level (0-100);
higher values retain more detail but increase file size | /// | `image_handling_mode` | `ImageHandlingMode` | `InMarkdown` | Determines how images are handled during content export | /// | `image_output_path` | `Option` | `None` | Output directory path for `ImageHandlingMode::Save` (mandatory for the saving mode) | +/// | `include_slide_comment` | `bool` | `true` | Weather the slide number comment is included or not (``) | /// /// # Example /// @@ -52,6 +53,7 @@ pub struct ParserConfig { pub quality: u8, pub image_handling_mode: ImageHandlingMode, pub image_output_path: Option, + pub include_slide_comment: bool, } impl Default for ParserConfig { @@ -62,6 +64,7 @@ impl Default for ParserConfig { quality: 80, image_handling_mode: ImageHandlingMode::InMarkdown, image_output_path: None, + include_slide_comment: true, } } } @@ -82,6 +85,7 @@ pub struct ParserConfigBuilder { image_quality: Option, image_handling_mode: Option, image_output_path: Option, + include_slide_comment: Option, } impl ParserConfigBuilder { @@ -119,6 +123,12 @@ impl ParserConfigBuilder { self } + /// Sets weather comments with current slide number are included or not + pub fn include_slide_comment(mut self, value: bool) -> Self { + self.include_slide_comment = Some(value); + self + } + /// Builds the final [`ParserConfig`] instance, applying default values for any fields that were not set. pub fn build(self) -> ParserConfig { ParserConfig { @@ -127,6 +137,7 @@ impl ParserConfigBuilder { quality: self.image_quality.unwrap_or(80), image_handling_mode: self.image_handling_mode.unwrap_or(ImageHandlingMode::InMarkdown), image_output_path: self.image_output_path, + include_slide_comment: self.include_slide_comment.unwrap_or(true), } } } \ No newline at end of file From f284fc3c8b7d0bc8311204fe75c5ebabd918b708 Mon Sep 17 00:00:00 2001 From: nilsk Date: Mon, 30 Jun 2025 21:18:52 +0200 Subject: [PATCH 2/2] use config to control the comment in the output md --- src/slide.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slide.rs b/src/slide.rs index fc2fb34..c79f166 100644 --- a/src/slide.rs +++ b/src/slide.rs @@ -73,7 +73,7 @@ impl Slide { /// - `None`: If a conversion error occurs during image encoding. pub fn convert_to_md(&self) -> Option { let mut slide_txt = String::new(); - slide_txt.push_str(format!("\n\n", self.slide_number).as_str()); + if self.config.include_slide_comment { slide_txt.push_str(format!("\n\n", self.slide_number).as_str()); } let mut image_count = 0; for element in &self.elements {