Create a render ast node type.
This commit is contained in:
parent
645ae26701
commit
b66ec507ef
0
default_environment/templates/html/ast_node.dust
Normal file
0
default_environment/templates/html/ast_node.dust
Normal file
@ -10,5 +10,9 @@
|
||||
{#.children}
|
||||
{>document_element/}
|
||||
{/.children}
|
||||
|
||||
{?.footnotes}
|
||||
{>real_footnote_definition/}
|
||||
{/.footnotes}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -0,0 +1 @@
|
||||
<div><sup><a id="{.definition_id}" href="{.reference_link}">{.label}</a></sup><div>{#.contents}{>ast_node/}{/.contents}</div></div>
|
407
src/context/ast_node.rs
Normal file
407
src/context/ast_node.rs
Normal file
@ -0,0 +1,407 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IAstNode;
|
||||
|
||||
use super::angle_link::RenderAngleLink;
|
||||
use super::babel_call::RenderBabelCall;
|
||||
use super::bold::RenderBold;
|
||||
use super::center_block::RenderCenterBlock;
|
||||
use super::citation::RenderCitation;
|
||||
use super::citation_reference::RenderCitationReference;
|
||||
use super::clock::RenderClock;
|
||||
use super::code::RenderCode;
|
||||
use super::comment::RenderComment;
|
||||
use super::comment_block::RenderCommentBlock;
|
||||
use super::diary_sexp::RenderDiarySexp;
|
||||
use super::drawer::RenderDrawer;
|
||||
use super::dynamic_block::RenderDynamicBlock;
|
||||
use super::entity::RenderEntity;
|
||||
use super::example_block::RenderExampleBlock;
|
||||
use super::export_block::RenderExportBlock;
|
||||
use super::export_snippet::RenderExportSnippet;
|
||||
use super::fixed_width_area::RenderFixedWidthArea;
|
||||
use super::footnote_definition::RenderFootnoteDefinition;
|
||||
use super::footnote_reference::RenderFootnoteReference;
|
||||
use super::horizontal_rule::RenderHorizontalRule;
|
||||
use super::inline_babel_call::RenderInlineBabelCall;
|
||||
use super::inline_source_block::RenderInlineSourceBlock;
|
||||
use super::italic::RenderItalic;
|
||||
use super::keyword::RenderKeyword;
|
||||
use super::latex_environment::RenderLatexEnvironment;
|
||||
use super::latex_fragment::RenderLatexFragment;
|
||||
use super::line_break::RenderLineBreak;
|
||||
use super::org_macro::RenderOrgMacro;
|
||||
use super::paragraph::RenderParagraph;
|
||||
use super::plain_link::RenderPlainLink;
|
||||
use super::plain_list::RenderPlainList;
|
||||
use super::plain_text::RenderPlainText;
|
||||
use super::planning::RenderPlanning;
|
||||
use super::property_drawer::RenderPropertyDrawer;
|
||||
use super::quote_block::RenderQuoteBlock;
|
||||
use super::radio_link::RenderRadioLink;
|
||||
use super::radio_target::RenderRadioTarget;
|
||||
use super::regular_link::RenderRegularLink;
|
||||
use super::special_block::RenderSpecialBlock;
|
||||
use super::src_block::RenderSrcBlock;
|
||||
use super::statistics_cookie::RenderStatisticsCookie;
|
||||
use super::strike_through::RenderStrikeThrough;
|
||||
use super::subscript::RenderSubscript;
|
||||
use super::superscript::RenderSuperscript;
|
||||
use super::table::RenderTable;
|
||||
use super::target::RenderTarget;
|
||||
use super::timestamp::RenderTimestamp;
|
||||
use super::underline::RenderUnderline;
|
||||
use super::verbatim::RenderVerbatim;
|
||||
use super::verse_block::RenderVerseBlock;
|
||||
use super::RenderHeading;
|
||||
use super::RenderSection;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderAstNode {
|
||||
Heading(RenderHeading),
|
||||
Section(RenderSection),
|
||||
Paragraph(RenderParagraph),
|
||||
PlainList(RenderPlainList),
|
||||
CenterBlock(RenderCenterBlock),
|
||||
QuoteBlock(RenderQuoteBlock),
|
||||
SpecialBlock(RenderSpecialBlock),
|
||||
DynamicBlock(RenderDynamicBlock),
|
||||
FootnoteDefinition(RenderFootnoteDefinition),
|
||||
Comment(RenderComment),
|
||||
Drawer(RenderDrawer),
|
||||
PropertyDrawer(RenderPropertyDrawer),
|
||||
Table(RenderTable),
|
||||
VerseBlock(RenderVerseBlock),
|
||||
CommentBlock(RenderCommentBlock),
|
||||
ExampleBlock(RenderExampleBlock),
|
||||
ExportBlock(RenderExportBlock),
|
||||
SrcBlock(RenderSrcBlock),
|
||||
Clock(RenderClock),
|
||||
DiarySexp(RenderDiarySexp),
|
||||
Planning(RenderPlanning),
|
||||
FixedWidthArea(RenderFixedWidthArea),
|
||||
HorizontalRule(RenderHorizontalRule),
|
||||
Keyword(RenderKeyword),
|
||||
BabelCall(RenderBabelCall),
|
||||
LatexEnvironment(RenderLatexEnvironment),
|
||||
Bold(RenderBold),
|
||||
Italic(RenderItalic),
|
||||
Underline(RenderUnderline),
|
||||
StrikeThrough(RenderStrikeThrough),
|
||||
Code(RenderCode),
|
||||
Verbatim(RenderVerbatim),
|
||||
PlainText(RenderPlainText),
|
||||
RegularLink(RenderRegularLink),
|
||||
RadioLink(RenderRadioLink),
|
||||
RadioTarget(RenderRadioTarget),
|
||||
PlainLink(RenderPlainLink),
|
||||
AngleLink(RenderAngleLink),
|
||||
OrgMacro(RenderOrgMacro),
|
||||
Entity(RenderEntity),
|
||||
LatexFragment(RenderLatexFragment),
|
||||
ExportSnippet(RenderExportSnippet),
|
||||
FootnoteReference(RenderFootnoteReference),
|
||||
Citation(RenderCitation),
|
||||
CitationReference(RenderCitationReference),
|
||||
InlineBabelCall(RenderInlineBabelCall),
|
||||
InlineSourceBlock(RenderInlineSourceBlock),
|
||||
LineBreak(RenderLineBreak),
|
||||
Target(RenderTarget),
|
||||
StatisticsCookie(RenderStatisticsCookie),
|
||||
Subscript(RenderSubscript),
|
||||
Superscript(RenderSuperscript),
|
||||
Timestamp(RenderTimestamp),
|
||||
}
|
||||
|
||||
pub(crate) trait IntoRenderAstNode {
|
||||
fn into_render_ast_node(
|
||||
&self,
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
) -> Result<RenderAstNode, CustomError>;
|
||||
}
|
||||
|
||||
impl IntoRenderAstNode for IAstNode {
|
||||
fn into_render_ast_node(
|
||||
&self,
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
) -> Result<RenderAstNode, CustomError> {
|
||||
match self {
|
||||
IAstNode::Heading(inner) => Ok(RenderAstNode::Heading(RenderHeading::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Section(inner) => Ok(RenderAstNode::Section(RenderSection::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Paragraph(inner) => Ok(RenderAstNode::Paragraph(RenderParagraph::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PlainList(inner) => Ok(RenderAstNode::PlainList(RenderPlainList::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::CenterBlock(inner) => Ok(RenderAstNode::CenterBlock(RenderCenterBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::QuoteBlock(inner) => Ok(RenderAstNode::QuoteBlock(RenderQuoteBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::SpecialBlock(inner) => Ok(RenderAstNode::SpecialBlock(
|
||||
RenderSpecialBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::DynamicBlock(inner) => Ok(RenderAstNode::DynamicBlock(
|
||||
RenderDynamicBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::FootnoteDefinition(inner) => Ok(RenderAstNode::FootnoteDefinition(
|
||||
RenderFootnoteDefinition::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::Comment(inner) => Ok(RenderAstNode::Comment(RenderComment::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Drawer(inner) => Ok(RenderAstNode::Drawer(RenderDrawer::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PropertyDrawer(inner) => Ok(RenderAstNode::PropertyDrawer(
|
||||
RenderPropertyDrawer::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::Table(inner) => Ok(RenderAstNode::Table(RenderTable::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::VerseBlock(inner) => Ok(RenderAstNode::VerseBlock(RenderVerseBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::CommentBlock(inner) => Ok(RenderAstNode::CommentBlock(
|
||||
RenderCommentBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::ExampleBlock(inner) => Ok(RenderAstNode::ExampleBlock(
|
||||
RenderExampleBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::ExportBlock(inner) => Ok(RenderAstNode::ExportBlock(RenderExportBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::SrcBlock(inner) => Ok(RenderAstNode::SrcBlock(RenderSrcBlock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Clock(inner) => Ok(RenderAstNode::Clock(RenderClock::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::DiarySexp(inner) => Ok(RenderAstNode::DiarySexp(RenderDiarySexp::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Planning(inner) => Ok(RenderAstNode::Planning(RenderPlanning::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::FixedWidthArea(inner) => Ok(RenderAstNode::FixedWidthArea(
|
||||
RenderFixedWidthArea::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::HorizontalRule(inner) => Ok(RenderAstNode::HorizontalRule(
|
||||
RenderHorizontalRule::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::Keyword(inner) => Ok(RenderAstNode::Keyword(RenderKeyword::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::BabelCall(inner) => Ok(RenderAstNode::BabelCall(RenderBabelCall::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::LatexEnvironment(inner) => Ok(RenderAstNode::LatexEnvironment(
|
||||
RenderLatexEnvironment::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::Bold(inner) => Ok(RenderAstNode::Bold(RenderBold::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Italic(inner) => Ok(RenderAstNode::Italic(RenderItalic::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Underline(inner) => Ok(RenderAstNode::Underline(RenderUnderline::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::StrikeThrough(inner) => Ok(RenderAstNode::StrikeThrough(
|
||||
RenderStrikeThrough::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::Code(inner) => Ok(RenderAstNode::Code(RenderCode::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Verbatim(inner) => Ok(RenderAstNode::Verbatim(RenderVerbatim::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PlainText(inner) => Ok(RenderAstNode::PlainText(RenderPlainText::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::RegularLink(inner) => Ok(RenderAstNode::RegularLink(RenderRegularLink::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::RadioLink(inner) => Ok(RenderAstNode::RadioLink(RenderRadioLink::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::RadioTarget(inner) => Ok(RenderAstNode::RadioTarget(RenderRadioTarget::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::PlainLink(inner) => Ok(RenderAstNode::PlainLink(RenderPlainLink::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::AngleLink(inner) => Ok(RenderAstNode::AngleLink(RenderAngleLink::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::OrgMacro(inner) => Ok(RenderAstNode::OrgMacro(RenderOrgMacro::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Entity(inner) => Ok(RenderAstNode::Entity(RenderEntity::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::LatexFragment(inner) => Ok(RenderAstNode::LatexFragment(
|
||||
RenderLatexFragment::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::ExportSnippet(inner) => Ok(RenderAstNode::ExportSnippet(
|
||||
RenderExportSnippet::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::FootnoteReference(inner) => Ok(RenderAstNode::FootnoteReference(
|
||||
RenderFootnoteReference::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::Citation(inner) => Ok(RenderAstNode::Citation(RenderCitation::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::CitationReference(inner) => Ok(RenderAstNode::CitationReference(
|
||||
RenderCitationReference::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::InlineBabelCall(inner) => Ok(RenderAstNode::InlineBabelCall(
|
||||
RenderInlineBabelCall::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::InlineSourceBlock(inner) => Ok(RenderAstNode::InlineSourceBlock(
|
||||
RenderInlineSourceBlock::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::LineBreak(inner) => Ok(RenderAstNode::LineBreak(RenderLineBreak::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Target(inner) => Ok(RenderAstNode::Target(RenderTarget::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::StatisticsCookie(inner) => Ok(RenderAstNode::StatisticsCookie(
|
||||
RenderStatisticsCookie::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IAstNode::Subscript(inner) => Ok(RenderAstNode::Subscript(RenderSubscript::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Superscript(inner) => Ok(RenderAstNode::Superscript(RenderSuperscript::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
IAstNode::Timestamp(inner) => Ok(RenderAstNode::Timestamp(RenderTimestamp::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
inner,
|
||||
)?)),
|
||||
}
|
||||
}
|
||||
}
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ impl RenderHeading {
|
||||
for obj in heading.title.iter() {
|
||||
ret.push(RenderObject::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
@ -43,8 +43,8 @@ impl RenderHeading {
|
||||
for obj in heading.children.iter() {
|
||||
ret.push(RenderDocumentElement::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
mod angle_link;
|
||||
mod ast_node;
|
||||
mod babel_call;
|
||||
mod blog_post_page;
|
||||
mod bold;
|
||||
|
@ -27,8 +27,8 @@ impl RenderParagraph {
|
||||
for obj in paragraph.children.iter() {
|
||||
ret.push(RenderObject::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ impl RenderPlainList {
|
||||
for obj in original.children.iter() {
|
||||
ret.push(RenderPlainListItem::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ impl RenderPlainListItem {
|
||||
for obj in original.tag.iter() {
|
||||
ret.push(RenderObject::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
@ -42,8 +42,8 @@ impl RenderPlainListItem {
|
||||
for obj in original.children.iter() {
|
||||
ret.push(RenderElement::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ impl RenderQuoteBlock {
|
||||
for obj in original.children.iter() {
|
||||
ret.push(RenderElement::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ impl RenderRegularLink {
|
||||
for obj in regular_link.children.iter() {
|
||||
ret.push(RenderObject::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ impl RenderSection {
|
||||
for obj in section.children.iter() {
|
||||
ret.push(RenderElement::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
output_directory,
|
||||
output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IAngleLink {}
|
||||
|
||||
impl IAngleLink {
|
||||
|
@ -55,7 +55,7 @@ use super::IVerseBlock;
|
||||
use crate::error::CustomError;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) enum IAstNode {
|
||||
Heading(IHeading),
|
||||
Section(ISection),
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IBabelCall {}
|
||||
|
||||
impl IBabelCall {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IBold {}
|
||||
|
||||
impl IBold {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ICenterBlock {}
|
||||
|
||||
impl ICenterBlock {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ICitation {}
|
||||
|
||||
impl ICitation {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ICitationReference {}
|
||||
|
||||
impl ICitationReference {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IClock {}
|
||||
|
||||
impl IClock {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ICode {}
|
||||
|
||||
impl ICode {
|
||||
|
@ -3,7 +3,7 @@ use crate::error::CustomError;
|
||||
use super::registry::Registry;
|
||||
|
||||
/// Essentially a no-op since the comment is not rendered.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IComment {}
|
||||
|
||||
impl IComment {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ICommentBlock {}
|
||||
|
||||
impl ICommentBlock {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IDiarySexp {}
|
||||
|
||||
impl IDiarySexp {
|
||||
|
@ -5,7 +5,7 @@ use super::IHeading;
|
||||
use super::ISection;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) enum IDocumentElement {
|
||||
Heading(IHeading),
|
||||
Section(ISection),
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IDrawer {}
|
||||
|
||||
impl IDrawer {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IDynamicBlock {}
|
||||
|
||||
impl IDynamicBlock {
|
||||
|
@ -27,7 +27,7 @@ use super::ITable;
|
||||
use super::IVerseBlock;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) enum IElement {
|
||||
Paragraph(IParagraph),
|
||||
PlainList(IPlainList),
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IEntity {
|
||||
pub(crate) html: String,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IExampleBlock {}
|
||||
|
||||
impl IExampleBlock {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IExportBlock {}
|
||||
|
||||
impl IExportBlock {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IExportSnippet {}
|
||||
|
||||
impl IExportSnippet {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IFixedWidthArea {}
|
||||
|
||||
impl IFixedWidthArea {
|
||||
|
@ -5,7 +5,7 @@ use super::registry::Registry;
|
||||
use super::IElement;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IFootnoteDefinition {}
|
||||
|
||||
impl IFootnoteDefinition {
|
||||
@ -22,8 +22,8 @@ impl IFootnoteDefinition {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct IRealFootnoteDefinition {
|
||||
footnote_id: usize,
|
||||
contents: Vec<IAstNode>,
|
||||
pub(crate) footnote_id: usize,
|
||||
pub(crate) contents: Vec<IAstNode>,
|
||||
}
|
||||
|
||||
impl IRealFootnoteDefinition {
|
||||
@ -37,4 +37,22 @@ impl IRealFootnoteDefinition {
|
||||
contents,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_display_label(&self) -> String {
|
||||
format!("{}", self.footnote_id + 1)
|
||||
}
|
||||
|
||||
/// Get an ID to refer to the first reference to this footnote definition.
|
||||
///
|
||||
/// This ID could, for example, be used for the id attribute in HTML for the reference anchor tag.
|
||||
pub(crate) fn get_reference_id(&self) -> String {
|
||||
format!("fnr.{}", self.get_display_label())
|
||||
}
|
||||
|
||||
/// Get an ID to refer to the footnote definition.
|
||||
///
|
||||
/// This ID could, for example, be used for the id attribute in HTML for the definition anchor tag.
|
||||
pub(crate) fn get_definition_id(&self) -> String {
|
||||
format!("fn.{}", self.get_display_label())
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IFootnoteReference {
|
||||
footnote_id: usize,
|
||||
duplicate_offset: usize,
|
||||
|
@ -4,7 +4,7 @@ use super::registry::Registry;
|
||||
use super::IDocumentElement;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IHeading {
|
||||
pub(crate) level: organic::types::HeadlineLevel,
|
||||
pub(crate) title: Vec<IObject>,
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IHorizontalRule {}
|
||||
|
||||
impl IHorizontalRule {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IInlineBabelCall {}
|
||||
|
||||
impl IInlineBabelCall {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IInlineSourceBlock {
|
||||
pub(crate) value: String,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IItalic {}
|
||||
|
||||
impl IItalic {
|
||||
|
@ -3,7 +3,7 @@ use crate::error::CustomError;
|
||||
use super::registry::Registry;
|
||||
|
||||
/// Essentially a no-op since the keyword is not rendered and any relevant impact on other elements is pulled from the parsed form of keyword.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IKeyword {}
|
||||
|
||||
impl IKeyword {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ILatexEnvironment {}
|
||||
|
||||
impl ILatexEnvironment {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ILatexFragment {}
|
||||
|
||||
impl ILatexFragment {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ILineBreak {}
|
||||
|
||||
impl ILineBreak {
|
||||
|
@ -62,6 +62,7 @@ mod util;
|
||||
mod verbatim;
|
||||
mod verse_block;
|
||||
pub(crate) use angle_link::IAngleLink;
|
||||
pub(crate) use ast_node::IAstNode;
|
||||
pub(crate) use babel_call::IBabelCall;
|
||||
pub(crate) use bold::IBold;
|
||||
pub(crate) use center_block::ICenterBlock;
|
||||
@ -84,6 +85,7 @@ pub(crate) use export_block::IExportBlock;
|
||||
pub(crate) use export_snippet::IExportSnippet;
|
||||
pub(crate) use fixed_width_area::IFixedWidthArea;
|
||||
pub(crate) use footnote_definition::IFootnoteDefinition;
|
||||
pub(crate) use footnote_definition::IRealFootnoteDefinition;
|
||||
pub(crate) use footnote_reference::IFootnoteReference;
|
||||
pub(crate) use heading::IHeading;
|
||||
pub(crate) use horizontal_rule::IHorizontalRule;
|
||||
|
@ -30,7 +30,7 @@ use super::verbatim::IVerbatim;
|
||||
use super::ITarget;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) enum IObject {
|
||||
Bold(IBold),
|
||||
Italic(IItalic),
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IOrgMacro {}
|
||||
|
||||
impl IOrgMacro {
|
||||
|
@ -39,13 +39,23 @@ impl BlogPostPage {
|
||||
));
|
||||
}
|
||||
|
||||
// TODO: Get footnote definitions
|
||||
let footnotes = {
|
||||
let footnote_definitions: Vec<_> = registry
|
||||
.get_footnote_ids()
|
||||
.map(|(id, def)| (id, def.clone()))
|
||||
.collect();
|
||||
let mut ret = Vec::new();
|
||||
for (id, def) in footnote_definitions.into_iter() {
|
||||
ret.push(IRealFootnoteDefinition::new(registry, id, def).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(BlogPostPage {
|
||||
path,
|
||||
title: get_title(&document),
|
||||
children,
|
||||
footnotes: Vec::new(), // TODO
|
||||
footnotes,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use crate::error::CustomError;
|
||||
use super::registry::Registry;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IParagraph {
|
||||
pub(crate) children: Vec<IObject>,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IPlainLink {}
|
||||
|
||||
impl IPlainLink {
|
||||
|
@ -3,7 +3,7 @@ use crate::error::CustomError;
|
||||
use super::registry::Registry;
|
||||
use super::IPlainListItem;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IPlainList {
|
||||
pub(crate) list_type: organic::types::PlainListType,
|
||||
pub(crate) children: Vec<IPlainListItem>,
|
||||
|
@ -4,7 +4,7 @@ use super::registry::Registry;
|
||||
use super::IElement;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IPlainListItem {
|
||||
pub(crate) tag: Vec<IObject>,
|
||||
pub(crate) children: Vec<IElement>,
|
||||
|
@ -3,7 +3,7 @@ use crate::intermediate::util::coalesce_whitespace;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IPlainText {
|
||||
pub(crate) source: String,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IPlanning {}
|
||||
|
||||
impl IPlanning {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IPropertyDrawer {}
|
||||
|
||||
impl IPropertyDrawer {
|
||||
|
@ -3,7 +3,7 @@ use crate::error::CustomError;
|
||||
use super::registry::Registry;
|
||||
use super::IElement;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IQuoteBlock {
|
||||
pub(crate) children: Vec<IElement>,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IRadioLink {}
|
||||
|
||||
impl IRadioLink {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IRadioTarget {}
|
||||
|
||||
impl IRadioTarget {
|
||||
|
@ -31,6 +31,13 @@ impl<'parse> Registry<'parse> {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_footnote_ids(&self) -> impl Iterator<Item = (usize, &Vec<IAstNode>)> {
|
||||
self.footnote_ids
|
||||
.iter()
|
||||
.map(|(_label, definition)| definition)
|
||||
.enumerate()
|
||||
}
|
||||
|
||||
/// Get a 0-indexed ID for a footnote.
|
||||
///
|
||||
/// This needs to be incremented to be 1-indexed for render.
|
||||
|
@ -3,7 +3,7 @@ use crate::error::CustomError;
|
||||
use super::registry::Registry;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IRegularLink {
|
||||
pub(crate) raw_link: String,
|
||||
pub(crate) children: Vec<IObject>,
|
||||
|
@ -3,7 +3,7 @@ use crate::error::CustomError;
|
||||
use super::registry::Registry;
|
||||
use super::IElement;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ISection {
|
||||
pub(crate) children: Vec<IElement>,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ISpecialBlock {}
|
||||
|
||||
impl ISpecialBlock {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ISrcBlock {
|
||||
pub(crate) lines: Vec<String>,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IStatisticsCookie {}
|
||||
|
||||
impl IStatisticsCookie {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IStrikeThrough {}
|
||||
|
||||
impl IStrikeThrough {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ISubscript {}
|
||||
|
||||
impl ISubscript {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ISuperscript {}
|
||||
|
||||
impl ISuperscript {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ITable {}
|
||||
|
||||
impl ITable {
|
||||
|
@ -3,7 +3,7 @@ use crate::intermediate::util::coalesce_whitespace;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ITarget {
|
||||
pub(crate) id: String,
|
||||
value: String,
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct ITimestamp {}
|
||||
|
||||
impl ITimestamp {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IUnderline {}
|
||||
|
||||
impl IUnderline {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IVerbatim {}
|
||||
|
||||
impl IVerbatim {
|
||||
|
@ -2,7 +2,7 @@ use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IVerseBlock {}
|
||||
|
||||
impl IVerseBlock {
|
||||
|
Loading…
x
Reference in New Issue
Block a user