Using the library
intern-core is the engine without the CLI - use it to build custom tooling,
reporting pipelines, or editor integrations.
[dependencies]
intern-core = { git = "https://github.com/markusz/intern" }
Checking a presentation
#![allow(unused)]
fn main() {
use intern_core::{
model::EMU_PER_PX,
reader::read_presentation,
rules::{all_rules, Limits, RuleContext},
};
let pres = read_presentation("deck.pptx")?;
let ctx = RuleContext {
threshold: 2 * EMU_PER_PX,
slide_width: pres.slide_width,
slide_height: pres.slide_height,
};
let limits = Limits { slide_count: 30, ..Limits::default() };
let violations: Vec<_> = all_rules(&limits)
.iter()
.flat_map(|rule| rule.check(&pres.slides, &ctx))
.collect();
for v in &violations {
println!("{:?} - {}", v.rule_id, v.message);
}
}
Key types
reader::read_presentation- parses a.pptxinto aPresentation(itsslidesplus the deck’s slide dimensions).rules::all_rules- builds every rule, parameterised byLimits.rules::Rule- the trait each rule implements:check(slides, ctx)takes a&[SlideData]and a&RuleContextand returns aVec<Violation>.rules::Violation- carries the rule id, slide, element, a structuredViolationMessage, and an optionalFix.writer::apply_fixes- applies a slice ofFixvalues to a.pptxin place.
Geometry is measured in EMU (English Metric Units); EMU_PER_PX converts a pixel
tolerance into the threshold the rules expect.