Files
natter/src/context/footnote_definition.rs

62 lines
1.7 KiB
Rust
Raw Normal View History

2023-10-27 17:08:58 -04:00
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IFootnoteDefinition;
2023-10-29 15:36:15 -04:00
use crate::intermediate::IRealFootnoteDefinition;
use super::ast_node::IntoRenderAstNode;
use super::ast_node::RenderAstNode;
2023-10-27 17:08:58 -04:00
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "footnote_definition")]
pub(crate) struct RenderFootnoteDefinition {}
impl RenderFootnoteDefinition {
2023-10-27 18:59:40 -04:00
pub(crate) fn new(
2023-10-29 22:31:29 -04:00
_config: &Config,
_output_directory: &Path,
_output_file: &Path,
_original: &IFootnoteDefinition,
2023-10-27 17:08:58 -04:00
) -> Result<RenderFootnoteDefinition, CustomError> {
Ok(RenderFootnoteDefinition {})
}
}
2023-10-29 15:36:15 -04:00
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "footnote_reference")]
pub(crate) struct RenderRealFootnoteDefinition {
definition_id: String,
reference_link: String,
2023-10-29 15:50:09 -04:00
label: String,
2023-10-29 15:36:15 -04:00
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()),
2023-10-29 15:50:09 -04:00
label: original.get_display_label(),
2023-10-29 15:36:15 -04:00
contents,
})
}
}