Add RenderPlainText.

This commit is contained in:
Tom Alexander 2023-10-27 13:01:45 -04:00
parent 744d3e50fb
commit 1ac39c2a6f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 39 additions and 3 deletions

View File

@ -15,4 +15,5 @@ pub(crate) use element::Element;
pub(crate) use heading::Heading;
pub(crate) use object::Object;
pub(crate) use page::BlogPostPage;
pub(crate) use plain_text::PlainText;
pub(crate) use section::Section;

View File

@ -4,6 +4,7 @@ mod element;
mod global_settings;
mod heading;
mod object;
mod plain_text;
mod section;
pub(crate) use blog_post_page::RenderBlogPostPage;

View File

@ -6,17 +6,28 @@ use crate::blog_post::Object;
use crate::config::Config;
use crate::error::CustomError;
use super::plain_text::RenderPlainText;
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub(crate) enum RenderObject {}
pub(crate) enum RenderObject {
PlainText(RenderPlainText),
}
impl RenderObject {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
section: &Object,
object: &Object,
) -> Result<RenderObject, CustomError> {
todo!()
match object {
Object::PlainText(inner) => Ok(RenderObject::PlainText(RenderPlainText::new(
config,
output_directory,
output_file,
inner,
)?)),
}
}
}

23
src/context/plain_text.rs Normal file
View File

@ -0,0 +1,23 @@
use std::path::Path;
use serde::Serialize;
use crate::blog_post::PlainText;
use crate::config::Config;
use crate::error::CustomError;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "heading")]
pub(crate) struct RenderPlainText {}
impl RenderPlainText {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
heading: &PlainText,
) -> Result<RenderPlainText, CustomError> {
Ok(RenderPlainText {})
}
}