typlite/writer/
mod.rs

1//! Writer implementations for different output formats
2
3#[cfg(feature = "docx")]
4pub mod docx;
5pub mod latex;
6pub mod markdown;
7pub mod text;
8
9#[cfg(feature = "docx")]
10pub use self::docx::DocxWriter;
11pub use latex::LaTeXWriter;
12pub use markdown::MarkdownWriter;
13pub use text::TextWriter;
14
15use crate::common::{Format, FormatWriter};
16
17/// Create a writer instance based on the specified format
18pub fn create_writer(format: Format) -> Box<dyn FormatWriter> {
19    match format {
20        Format::Md => Box::new(markdown::MarkdownWriter::new()),
21        Format::LaTeX => Box::new(latex::LaTeXWriter::new()),
22        Format::Text => Box::new(text::TextWriter::new()),
23        #[cfg(feature = "docx")]
24        Format::Docx => Box::new(docx::DocxWriter::new()),
25    }
26}
27
28pub struct WriterFactory;
29
30impl WriterFactory {
31    pub fn create(format: Format) -> Box<dyn FormatWriter> {
32        create_writer(format)
33    }
34}