mirror of
https://github.com/mfontanini/presenterm.git
synced 2025-05-05 15:32:58 +00:00
chore: rename module pdf
to output
This commit is contained in:
parent
519aad16e8
commit
76561b1281
@ -2,7 +2,7 @@ use crate::{
|
||||
MarkdownParser, Resources,
|
||||
code::execute::SnippetExecutor,
|
||||
config::{KeyBindingsConfig, PauseExportPolicy},
|
||||
export::pdf::{ExportRenderer, Renderer},
|
||||
export::output::{ExportRenderer, OutputType},
|
||||
markdown::{parse::ParseError, text_style::Color},
|
||||
presentation::{
|
||||
Presentation,
|
||||
@ -102,7 +102,7 @@ impl<'a> Exporter<'a> {
|
||||
&mut self,
|
||||
presentation_path: &Path,
|
||||
output_directory: OutputDirectory,
|
||||
renderer: Renderer,
|
||||
renderer: OutputType,
|
||||
) -> Result<ExportRenderer, ExportError> {
|
||||
let content = fs::read_to_string(presentation_path).map_err(ExportError::ReadPresentation)?;
|
||||
let elements = self.parser.parse(&content)?;
|
||||
@ -150,7 +150,7 @@ impl<'a> Exporter<'a> {
|
||||
Self::validate_weasyprint_exists()?;
|
||||
Self::log("weasyprint installation found")?;
|
||||
|
||||
let render = self.build_renderer(presentation_path, output_directory, Renderer::Pdf)?;
|
||||
let render = self.build_renderer(presentation_path, output_directory, OutputType::Pdf)?;
|
||||
|
||||
let pdf_path = match output_path {
|
||||
Some(path) => path.to_path_buf(),
|
||||
@ -180,7 +180,7 @@ impl<'a> Exporter<'a> {
|
||||
self.dimensions.rows, self.dimensions.columns, self.dimensions.width, self.dimensions.height
|
||||
);
|
||||
|
||||
let render = self.build_renderer(presentation_path, output_directory, Renderer::Html)?;
|
||||
let render = self.build_renderer(presentation_path, output_directory, OutputType::Html)?;
|
||||
|
||||
let output_path = match output_path {
|
||||
Some(path) => path.to_path_buf(),
|
||||
|
@ -1,3 +1,3 @@
|
||||
pub mod exporter;
|
||||
pub(crate) mod html;
|
||||
pub(crate) mod pdf;
|
||||
pub(crate) mod output;
|
||||
|
@ -124,21 +124,21 @@ impl ContentManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum Renderer {
|
||||
pub(crate) enum OutputType {
|
||||
Pdf,
|
||||
Html,
|
||||
}
|
||||
|
||||
pub(crate) struct ExportRenderer {
|
||||
content_manager: ContentManager,
|
||||
output_type: Renderer,
|
||||
output_type: OutputType,
|
||||
dimensions: WindowSize,
|
||||
html_body: String,
|
||||
background_color: Option<String>,
|
||||
}
|
||||
|
||||
impl ExportRenderer {
|
||||
pub(crate) fn new(dimensions: WindowSize, output_directory: OutputDirectory, output_type: Renderer) -> Self {
|
||||
pub(crate) fn new(dimensions: WindowSize, output_directory: OutputDirectory, output_type: OutputType) -> Self {
|
||||
let image_manager = ContentManager::new(output_directory);
|
||||
Self {
|
||||
content_manager: image_manager,
|
||||
@ -218,8 +218,8 @@ impl ExportRenderer {
|
||||
}}"
|
||||
);
|
||||
let html_script = match self.output_type {
|
||||
Renderer::Pdf => String::new(),
|
||||
Renderer::Html => {
|
||||
OutputType::Pdf => String::new(),
|
||||
OutputType::Html => {
|
||||
format!(
|
||||
"
|
||||
<script>
|
||||
@ -246,7 +246,7 @@ impl ExportRenderer {
|
||||
let html_path = self.content_manager.persist_file("index.html", html.as_bytes())?;
|
||||
|
||||
match self.output_type {
|
||||
Renderer::Pdf => {
|
||||
OutputType::Pdf => {
|
||||
ThirdPartyTools::weasyprint(&[
|
||||
"--presentational-hints",
|
||||
"-e",
|
||||
@ -256,7 +256,7 @@ impl ExportRenderer {
|
||||
])
|
||||
.run()?;
|
||||
}
|
||||
Renderer::Html => {
|
||||
OutputType::Html => {
|
||||
fs::write(output_path, html.as_bytes())?;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user