#[cfg(feature = "fs")]
use std::path::{Path, PathBuf};
use crate::core::ports::{RenderBackend, ResourceResolver};
use crate::core::{BuiltInTheme, LayoutMode, PageSize, ThemeConfig};
pub enum MarkdownSource<'a> {
#[cfg(feature = "fs")]
Path(&'a Path),
Text(&'a str),
Bytes(&'a [u8]),
}
pub enum OutputTarget<'a> {
#[cfg(feature = "fs")]
File(&'a Path),
#[cfg(feature = "fs")]
Directory(&'a Path),
Memory,
#[doc(hidden)]
__Lifetime(std::marker::PhantomData<&'a ()>),
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum RenderBackendSelection {
#[default]
Minimal,
#[cfg(feature = "renderer-typst")]
Typst,
}
pub struct ConvertOptions<'a> {
pub source: Option<MarkdownSource<'a>>,
pub output: Option<OutputTarget<'a>>,
pub output_file_name: Option<&'a str>,
pub page_size: PageSize,
pub layout_mode: LayoutMode,
pub theme: ThemeConfig,
pub backend: RenderBackendSelection,
pub resource_resolver: Option<Box<dyn ResourceResolver>>,
pub renderer: Option<Box<dyn RenderBackend>>,
}
impl<'a> Default for ConvertOptions<'a> {
fn default() -> Self {
Self {
source: None,
output: None,
output_file_name: None,
page_size: PageSize::A4,
layout_mode: LayoutMode::Paged,
theme: ThemeConfig {
built_in: Some(BuiltInTheme::Professional),
custom_theme_json: None,
},
backend: RenderBackendSelection::Minimal,
resource_resolver: None,
renderer: None,
}
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct PdfOutput {
pub bytes: Option<Vec<u8>>,
#[cfg(feature = "fs")]
pub written_path: Option<PathBuf>,
}