Add children to heading.
This commit is contained in:
@@ -12,10 +12,10 @@ use crate::intermediate::IAngleLink;
|
||||
pub(crate) struct RenderAngleLink {}
|
||||
|
||||
impl RenderAngleLink {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IAngleLink,
|
||||
) -> Result<RenderAngleLink, CustomError> {
|
||||
Ok(RenderAngleLink {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IBabelCall;
|
||||
pub(crate) struct RenderBabelCall {}
|
||||
|
||||
impl RenderBabelCall {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IBabelCall,
|
||||
) -> Result<RenderBabelCall, CustomError> {
|
||||
Ok(RenderBabelCall {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IBold;
|
||||
pub(crate) struct RenderBold {}
|
||||
|
||||
impl RenderBold {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IBold,
|
||||
) -> Result<RenderBold, CustomError> {
|
||||
Ok(RenderBold {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ICenterBlock;
|
||||
pub(crate) struct RenderCenterBlock {}
|
||||
|
||||
impl RenderCenterBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ICenterBlock,
|
||||
) -> Result<RenderCenterBlock, CustomError> {
|
||||
Ok(RenderCenterBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ICitation;
|
||||
pub(crate) struct RenderCitation {}
|
||||
|
||||
impl RenderCitation {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ICitation,
|
||||
) -> Result<RenderCitation, CustomError> {
|
||||
Ok(RenderCitation {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ICitationReference;
|
||||
pub(crate) struct RenderCitationReference {}
|
||||
|
||||
impl RenderCitationReference {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ICitationReference,
|
||||
) -> Result<RenderCitationReference, CustomError> {
|
||||
Ok(RenderCitationReference {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IClock;
|
||||
pub(crate) struct RenderClock {}
|
||||
|
||||
impl RenderClock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IClock,
|
||||
) -> Result<RenderClock, CustomError> {
|
||||
Ok(RenderClock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ICode;
|
||||
pub(crate) struct RenderCode {}
|
||||
|
||||
impl RenderCode {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ICode,
|
||||
) -> Result<RenderCode, CustomError> {
|
||||
Ok(RenderCode {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IComment;
|
||||
pub(crate) struct RenderComment {}
|
||||
|
||||
impl RenderComment {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IComment,
|
||||
) -> Result<RenderComment, CustomError> {
|
||||
Ok(RenderComment {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ICommentBlock;
|
||||
pub(crate) struct RenderCommentBlock {}
|
||||
|
||||
impl RenderCommentBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ICommentBlock,
|
||||
) -> Result<RenderCommentBlock, CustomError> {
|
||||
Ok(RenderCommentBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IDiarySexp;
|
||||
pub(crate) struct RenderDiarySexp {}
|
||||
|
||||
impl RenderDiarySexp {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDiarySexp,
|
||||
) -> Result<RenderDiarySexp, CustomError> {
|
||||
Ok(RenderDiarySexp {})
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IDocumentElement;
|
||||
|
||||
use super::RenderHeading;
|
||||
use super::RenderSection;
|
||||
|
||||
@@ -9,3 +15,21 @@ pub(crate) enum RenderDocumentElement {
|
||||
Heading(RenderHeading),
|
||||
Section(RenderSection),
|
||||
}
|
||||
|
||||
impl RenderDocumentElement {
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDocumentElement,
|
||||
) -> Result<RenderDocumentElement, CustomError> {
|
||||
match original {
|
||||
IDocumentElement::Heading(inner) => Ok(RenderDocumentElement::Heading(
|
||||
RenderHeading::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
IDocumentElement::Section(inner) => Ok(RenderDocumentElement::Section(
|
||||
RenderSection::new(config, output_directory, output_file, inner)?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IDrawer;
|
||||
pub(crate) struct RenderDrawer {}
|
||||
|
||||
impl RenderDrawer {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDrawer,
|
||||
) -> Result<RenderDrawer, CustomError> {
|
||||
Ok(RenderDrawer {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IDynamicBlock;
|
||||
pub(crate) struct RenderDynamicBlock {}
|
||||
|
||||
impl RenderDynamicBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IDynamicBlock,
|
||||
) -> Result<RenderDynamicBlock, CustomError> {
|
||||
Ok(RenderDynamicBlock {})
|
||||
|
||||
@@ -61,10 +61,10 @@ pub(crate) enum RenderElement {
|
||||
}
|
||||
|
||||
impl RenderElement {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
element: &IElement,
|
||||
) -> Result<RenderElement, CustomError> {
|
||||
match element {
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IEntity;
|
||||
pub(crate) struct RenderEntity {}
|
||||
|
||||
impl RenderEntity {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IEntity,
|
||||
) -> Result<RenderEntity, CustomError> {
|
||||
Ok(RenderEntity {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IExampleBlock;
|
||||
pub(crate) struct RenderExampleBlock {}
|
||||
|
||||
impl RenderExampleBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IExampleBlock,
|
||||
) -> Result<RenderExampleBlock, CustomError> {
|
||||
Ok(RenderExampleBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IExportBlock;
|
||||
pub(crate) struct RenderExportBlock {}
|
||||
|
||||
impl RenderExportBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IExportBlock,
|
||||
) -> Result<RenderExportBlock, CustomError> {
|
||||
Ok(RenderExportBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IExportSnippet;
|
||||
pub(crate) struct RenderExportSnippet {}
|
||||
|
||||
impl RenderExportSnippet {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IExportSnippet,
|
||||
) -> Result<RenderExportSnippet, CustomError> {
|
||||
Ok(RenderExportSnippet {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IFixedWidthArea;
|
||||
pub(crate) struct RenderFixedWidthArea {}
|
||||
|
||||
impl RenderFixedWidthArea {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IFixedWidthArea,
|
||||
) -> Result<RenderFixedWidthArea, CustomError> {
|
||||
Ok(RenderFixedWidthArea {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IFootnoteDefinition;
|
||||
pub(crate) struct RenderFootnoteDefinition {}
|
||||
|
||||
impl RenderFootnoteDefinition {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IFootnoteDefinition,
|
||||
) -> Result<RenderFootnoteDefinition, CustomError> {
|
||||
Ok(RenderFootnoteDefinition {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IFootnoteReference;
|
||||
pub(crate) struct RenderFootnoteReference {}
|
||||
|
||||
impl RenderFootnoteReference {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IFootnoteReference,
|
||||
) -> Result<RenderFootnoteReference, CustomError> {
|
||||
Ok(RenderFootnoteReference {})
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IHeading;
|
||||
|
||||
use super::RenderDocumentElement;
|
||||
use super::RenderObject;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@@ -14,23 +15,46 @@ use super::RenderObject;
|
||||
pub(crate) struct RenderHeading {
|
||||
level: organic::types::HeadlineLevel,
|
||||
title: Vec<RenderObject>,
|
||||
children: Vec<RenderDocumentElement>,
|
||||
}
|
||||
|
||||
impl RenderHeading {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
heading: &IHeading,
|
||||
) -> Result<RenderHeading, CustomError> {
|
||||
let title = heading
|
||||
.title
|
||||
.iter()
|
||||
.map(|obj| RenderObject::new(config, &output_directory, &output_file, obj))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let title = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in heading.title.iter() {
|
||||
ret.push(RenderObject::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in heading.children.iter() {
|
||||
ret.push(RenderDocumentElement::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderHeading {
|
||||
level: heading.level,
|
||||
level: heading.level + 1, // Adding 1 because the page title is going to be h1.
|
||||
title,
|
||||
children,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IHorizontalRule;
|
||||
pub(crate) struct RenderHorizontalRule {}
|
||||
|
||||
impl RenderHorizontalRule {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IHorizontalRule,
|
||||
) -> Result<RenderHorizontalRule, CustomError> {
|
||||
Ok(RenderHorizontalRule {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IInlineBabelCall;
|
||||
pub(crate) struct RenderInlineBabelCall {}
|
||||
|
||||
impl RenderInlineBabelCall {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IInlineBabelCall,
|
||||
) -> Result<RenderInlineBabelCall, CustomError> {
|
||||
Ok(RenderInlineBabelCall {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IInlineSourceBlock;
|
||||
pub(crate) struct RenderInlineSourceBlock {}
|
||||
|
||||
impl RenderInlineSourceBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IInlineSourceBlock,
|
||||
) -> Result<RenderInlineSourceBlock, CustomError> {
|
||||
Ok(RenderInlineSourceBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IItalic;
|
||||
pub(crate) struct RenderItalic {}
|
||||
|
||||
impl RenderItalic {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IItalic,
|
||||
) -> Result<RenderItalic, CustomError> {
|
||||
Ok(RenderItalic {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IKeyword;
|
||||
pub(crate) struct RenderKeyword {}
|
||||
|
||||
impl RenderKeyword {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
keyword: &IKeyword,
|
||||
) -> Result<RenderKeyword, CustomError> {
|
||||
Ok(RenderKeyword {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ILatexEnvironment;
|
||||
pub(crate) struct RenderLatexEnvironment {}
|
||||
|
||||
impl RenderLatexEnvironment {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ILatexEnvironment,
|
||||
) -> Result<RenderLatexEnvironment, CustomError> {
|
||||
Ok(RenderLatexEnvironment {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ILatexFragment;
|
||||
pub(crate) struct RenderLatexFragment {}
|
||||
|
||||
impl RenderLatexFragment {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ILatexFragment,
|
||||
) -> Result<RenderLatexFragment, CustomError> {
|
||||
Ok(RenderLatexFragment {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ILineBreak;
|
||||
pub(crate) struct RenderLineBreak {}
|
||||
|
||||
impl RenderLineBreak {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ILineBreak,
|
||||
) -> Result<RenderLineBreak, CustomError> {
|
||||
Ok(RenderLineBreak {})
|
||||
|
||||
@@ -67,10 +67,10 @@ pub(crate) enum RenderObject {
|
||||
}
|
||||
|
||||
impl RenderObject {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
object: &IObject,
|
||||
) -> Result<RenderObject, CustomError> {
|
||||
match object {
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IOrgMacro;
|
||||
pub(crate) struct RenderOrgMacro {}
|
||||
|
||||
impl RenderOrgMacro {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IOrgMacro,
|
||||
) -> Result<RenderOrgMacro, CustomError> {
|
||||
Ok(RenderOrgMacro {})
|
||||
|
||||
@@ -16,17 +16,25 @@ pub(crate) struct RenderParagraph {
|
||||
}
|
||||
|
||||
impl RenderParagraph {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
paragraph: &IParagraph,
|
||||
) -> Result<RenderParagraph, CustomError> {
|
||||
let children = paragraph
|
||||
.children
|
||||
.iter()
|
||||
.map(|obj| RenderObject::new(config, &output_directory, &output_file, obj))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in paragraph.children.iter() {
|
||||
ret.push(RenderObject::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderParagraph { children })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IPlainLink;
|
||||
pub(crate) struct RenderPlainLink {}
|
||||
|
||||
impl RenderPlainLink {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IPlainLink,
|
||||
) -> Result<RenderPlainLink, CustomError> {
|
||||
Ok(RenderPlainLink {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IPlainList;
|
||||
pub(crate) struct RenderPlainList {}
|
||||
|
||||
impl RenderPlainList {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IPlainList,
|
||||
) -> Result<RenderPlainList, CustomError> {
|
||||
Ok(RenderPlainList {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IPlainText;
|
||||
pub(crate) struct RenderPlainText {}
|
||||
|
||||
impl RenderPlainText {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
heading: &IPlainText,
|
||||
) -> Result<RenderPlainText, CustomError> {
|
||||
Ok(RenderPlainText {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IPlanning;
|
||||
pub(crate) struct RenderPlanning {}
|
||||
|
||||
impl RenderPlanning {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IPlanning,
|
||||
) -> Result<RenderPlanning, CustomError> {
|
||||
Ok(RenderPlanning {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IPropertyDrawer;
|
||||
pub(crate) struct RenderPropertyDrawer {}
|
||||
|
||||
impl RenderPropertyDrawer {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IPropertyDrawer,
|
||||
) -> Result<RenderPropertyDrawer, CustomError> {
|
||||
Ok(RenderPropertyDrawer {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IQuoteBlock;
|
||||
pub(crate) struct RenderQuoteBlock {}
|
||||
|
||||
impl RenderQuoteBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IQuoteBlock,
|
||||
) -> Result<RenderQuoteBlock, CustomError> {
|
||||
Ok(RenderQuoteBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IRadioLink;
|
||||
pub(crate) struct RenderRadioLink {}
|
||||
|
||||
impl RenderRadioLink {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IRadioLink,
|
||||
) -> Result<RenderRadioLink, CustomError> {
|
||||
Ok(RenderRadioLink {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IRadioTarget;
|
||||
pub(crate) struct RenderRadioTarget {}
|
||||
|
||||
impl RenderRadioTarget {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IRadioTarget,
|
||||
) -> Result<RenderRadioTarget, CustomError> {
|
||||
Ok(RenderRadioTarget {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IRegularLink;
|
||||
pub(crate) struct RenderRegularLink {}
|
||||
|
||||
impl RenderRegularLink {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IRegularLink,
|
||||
) -> Result<RenderRegularLink, CustomError> {
|
||||
Ok(RenderRegularLink {})
|
||||
|
||||
@@ -16,17 +16,24 @@ pub(crate) struct RenderSection {
|
||||
}
|
||||
|
||||
impl RenderSection {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
section: &ISection,
|
||||
) -> Result<RenderSection, CustomError> {
|
||||
let children = section
|
||||
.children
|
||||
.iter()
|
||||
.map(|obj| RenderElement::new(config, &output_directory, &output_file, obj))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in section.children.iter() {
|
||||
ret.push(RenderElement::new(
|
||||
config,
|
||||
&output_directory,
|
||||
&output_file,
|
||||
obj,
|
||||
)?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(RenderSection { children })
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ISpecialBlock;
|
||||
pub(crate) struct RenderSpecialBlock {}
|
||||
|
||||
impl RenderSpecialBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ISpecialBlock,
|
||||
) -> Result<RenderSpecialBlock, CustomError> {
|
||||
Ok(RenderSpecialBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ISrcBlock;
|
||||
pub(crate) struct RenderSrcBlock {}
|
||||
|
||||
impl RenderSrcBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ISrcBlock,
|
||||
) -> Result<RenderSrcBlock, CustomError> {
|
||||
Ok(RenderSrcBlock {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IStatisticsCookie;
|
||||
pub(crate) struct RenderStatisticsCookie {}
|
||||
|
||||
impl RenderStatisticsCookie {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IStatisticsCookie,
|
||||
) -> Result<RenderStatisticsCookie, CustomError> {
|
||||
Ok(RenderStatisticsCookie {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IStrikeThrough;
|
||||
pub(crate) struct RenderStrikeThrough {}
|
||||
|
||||
impl RenderStrikeThrough {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IStrikeThrough,
|
||||
) -> Result<RenderStrikeThrough, CustomError> {
|
||||
Ok(RenderStrikeThrough {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ISubscript;
|
||||
pub(crate) struct RenderSubscript {}
|
||||
|
||||
impl RenderSubscript {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ISubscript,
|
||||
) -> Result<RenderSubscript, CustomError> {
|
||||
Ok(RenderSubscript {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ISuperscript;
|
||||
pub(crate) struct RenderSuperscript {}
|
||||
|
||||
impl RenderSuperscript {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ISuperscript,
|
||||
) -> Result<RenderSuperscript, CustomError> {
|
||||
Ok(RenderSuperscript {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ITable;
|
||||
pub(crate) struct RenderTable {}
|
||||
|
||||
impl RenderTable {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &ITable,
|
||||
) -> Result<RenderTable, CustomError> {
|
||||
Ok(RenderTable {})
|
||||
|
||||
@@ -14,10 +14,10 @@ pub(crate) struct RenderTarget {
|
||||
}
|
||||
|
||||
impl RenderTarget {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
target: &ITarget,
|
||||
) -> Result<RenderTarget, CustomError> {
|
||||
Ok(RenderTarget {
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::ITimestamp;
|
||||
pub(crate) struct RenderTimestamp {}
|
||||
|
||||
impl RenderTimestamp {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &ITimestamp,
|
||||
) -> Result<RenderTimestamp, CustomError> {
|
||||
Ok(RenderTimestamp {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IUnderline;
|
||||
pub(crate) struct RenderUnderline {}
|
||||
|
||||
impl RenderUnderline {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IUnderline,
|
||||
) -> Result<RenderUnderline, CustomError> {
|
||||
Ok(RenderUnderline {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IVerbatim;
|
||||
pub(crate) struct RenderVerbatim {}
|
||||
|
||||
impl RenderVerbatim {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
comment: &IVerbatim,
|
||||
) -> Result<RenderVerbatim, CustomError> {
|
||||
Ok(RenderVerbatim {})
|
||||
|
||||
@@ -12,10 +12,10 @@ use crate::intermediate::IVerseBlock;
|
||||
pub(crate) struct RenderVerseBlock {}
|
||||
|
||||
impl RenderVerseBlock {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
pub(crate) fn new(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
output_directory: &Path,
|
||||
output_file: &Path,
|
||||
original: &IVerseBlock,
|
||||
) -> Result<RenderVerseBlock, CustomError> {
|
||||
Ok(RenderVerseBlock {})
|
||||
|
||||
@@ -6,13 +6,10 @@ use crate::config::Config;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::RenderBlogPostPage;
|
||||
use crate::context::RenderDocumentElement;
|
||||
use crate::context::RenderHeading;
|
||||
use crate::context::RenderSection;
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::BlogPost;
|
||||
use super::BlogPostPage;
|
||||
use super::IDocumentElement;
|
||||
|
||||
pub(crate) fn convert_blog_post_page_to_render_context<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
config: &Config,
|
||||
@@ -47,24 +44,12 @@ pub(crate) fn convert_blog_post_page_to_render_context<D: AsRef<Path>, F: AsRef<
|
||||
let mut children = Vec::new();
|
||||
|
||||
for child in page.children.iter() {
|
||||
match child {
|
||||
IDocumentElement::Heading(heading) => {
|
||||
children.push(RenderDocumentElement::Heading(RenderHeading::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
heading,
|
||||
)?));
|
||||
}
|
||||
IDocumentElement::Section(section) => {
|
||||
children.push(RenderDocumentElement::Section(RenderSection::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
section,
|
||||
)?));
|
||||
}
|
||||
}
|
||||
children.push(RenderDocumentElement::new(
|
||||
config,
|
||||
output_directory,
|
||||
output_file,
|
||||
child,
|
||||
)?);
|
||||
}
|
||||
|
||||
children
|
||||
|
||||
@@ -1,8 +1,31 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
use super::IHeading;
|
||||
use super::ISection;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum IDocumentElement {
|
||||
Heading(IHeading),
|
||||
Section(ISection),
|
||||
}
|
||||
|
||||
impl IDocumentElement {
|
||||
pub(crate) fn new<'parse, 'b>(
|
||||
registry: &'b mut Registry<'parse>,
|
||||
original: &'b organic::types::DocumentElement<'parse>,
|
||||
) -> BoxFuture<'b, Result<IDocumentElement, CustomError>> {
|
||||
async move {
|
||||
match original {
|
||||
organic::types::DocumentElement::Heading(inner) => Ok(IDocumentElement::Heading(
|
||||
IHeading::new(registry, inner).await?,
|
||||
)),
|
||||
organic::types::DocumentElement::Section(inner) => Ok(IDocumentElement::Section(
|
||||
ISection::new(registry, inner).await?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::registry::Registry;
|
||||
use super::IDocumentElement;
|
||||
use super::IObject;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct IHeading {
|
||||
pub(crate) level: organic::types::HeadlineLevel,
|
||||
pub(crate) title: Vec<IObject>,
|
||||
pub(crate) children: Vec<IDocumentElement>,
|
||||
}
|
||||
|
||||
impl IHeading {
|
||||
@@ -21,9 +23,17 @@ impl IHeading {
|
||||
}
|
||||
ret
|
||||
};
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in heading.children.iter() {
|
||||
ret.push(IDocumentElement::new(registry, obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
Ok(IHeading {
|
||||
title,
|
||||
level: heading.level,
|
||||
children,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user