Create a render ast node type.
This commit is contained in:
@@ -5,6 +5,10 @@ use serde::Serialize;
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IFootnoteDefinition;
|
||||
use crate::intermediate::IRealFootnoteDefinition;
|
||||
|
||||
use super::ast_node::IntoRenderAstNode;
|
||||
use super::ast_node::RenderAstNode;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
@@ -21,3 +25,35 @@ impl RenderFootnoteDefinition {
|
||||
Ok(RenderFootnoteDefinition {})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "footnote_reference")]
|
||||
pub(crate) struct RenderRealFootnoteDefinition {
|
||||
definition_id: String,
|
||||
reference_link: String,
|
||||
contents: Vec<RenderAstNode>,
|
||||
}
|
||||
|
||||
impl RenderRealFootnoteDefinition {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IRealFootnoteDefinition,
|
||||
) -> Result<RenderRealFootnoteDefinition, CustomError> {
|
||||
let contents = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.contents.iter() {
|
||||
ret.push(obj.into_render_ast_node(config, output_directory, output_file)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderRealFootnoteDefinition {
|
||||
definition_id: original.get_definition_id(),
|
||||
reference_link: format!("#{}", original.get_reference_id()),
|
||||
contents,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user