Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_file/examples/make_pptx.rs

1.5 KiB, 5 runs

created by r1870400018:22867, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1//! Writes a `.pptx` from a Markdown file, so an external reader can be asked what it makes of it.
2//!
3//! A deck is the format where a self-consistent test proves least, because the whole of the risk is
4//! the SKELETON: a slide points at a layout, a layout at a master, a master at a theme, and a file
5//! with any link missing opens with a repair prompt rather than an error. Nothing this crate's own
6//! reader does would notice.
7//!
8//! ```text
9//! cargo run -p oxedyne_fe2o3_file --example make_pptx -- in.md out.pptx
10//! soffice --headless --convert-to pdf out.pptx
11//! ```
12//!
13//! [Written with AI entirely](https://need2know.ai/entirely-ai/code)\
14//! Anthropic Claude
15
16use oxedyne_fe2o3_core::prelude::*;
17use oxedyne_fe2o3_file::office::deck::Deck;
18use oxedyne_fe2o3_file::office::pptx;
19use oxedyne_fe2o3_text::doc::markdown;
20
21fn main() -> Outcome<()> {
22 let args: Vec<String> = std::env::args().collect();
23 if args.len() != 3 {
24 return Err(err!("Usage: make_pptx <markdown in> <pptx out>"; Invalid, Input));
25 }
26 let src = res!(std::fs::read_to_string(&args[1]), IO, File);
27 let doc = res!(markdown::parse(&src));
28 let deck = Deck::from_doc(&doc);
29 let (bytes, left) = res!(pptx::write(&deck));
30 res!(std::fs::write(&args[2], &bytes), IO, File);
31 println!("{}: {} bytes, {} slides", args[2], bytes.len(), deck.slides.len());
32 for src in &left.images {
33 println!("not carried: the image at {}", src);
34 }
35 if left.notes > 0 {
36 println!("not carried: speaker's notes on {} slide(s)", left.notes);
37 }
38 Ok(())
39}