|
|
@ -5,6 +5,7 @@ use crate::elements::{
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use crate::parser::inline::ParseInline;
|
|
|
|
use crate::parser::inline::ParseInline;
|
|
|
|
use crate::parser::line::ParseLine;
|
|
|
|
use crate::parser::line::ParseLine;
|
|
|
|
|
|
|
|
use crate::parser::ImportType;
|
|
|
|
use crate::Parser;
|
|
|
|
use crate::Parser;
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) trait ParseBlock {
|
|
|
|
pub(crate) trait ParseBlock {
|
|
|
@ -16,7 +17,7 @@ pub(crate) trait ParseBlock {
|
|
|
|
fn parse_paragraph(&mut self) -> ParseResult<Paragraph>;
|
|
|
|
fn parse_paragraph(&mut self) -> ParseResult<Paragraph>;
|
|
|
|
fn parse_list(&mut self) -> ParseResult<List>;
|
|
|
|
fn parse_list(&mut self) -> ParseResult<List>;
|
|
|
|
fn parse_table(&mut self) -> ParseResult<Table>;
|
|
|
|
fn parse_table(&mut self) -> ParseResult<Table>;
|
|
|
|
fn parse_import(&mut self) -> ParseResult<Import>;
|
|
|
|
fn parse_import(&mut self) -> ParseResult<Option<Import>>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ParseBlock for Parser {
|
|
|
|
impl ParseBlock for Parser {
|
|
|
@ -44,7 +45,11 @@ impl ParseBlock for Parser {
|
|
|
|
} else if let Ok(quote) = self.parse_quote() {
|
|
|
|
} else if let Ok(quote) = self.parse_quote() {
|
|
|
|
Block::Quote(quote)
|
|
|
|
Block::Quote(quote)
|
|
|
|
} else if let Ok(import) = self.parse_import() {
|
|
|
|
} else if let Ok(import) = self.parse_import() {
|
|
|
|
|
|
|
|
if let Some(import) = import {
|
|
|
|
Block::Import(import)
|
|
|
|
Block::Import(import)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Block::Null
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if let Some(_) = self.section_return {
|
|
|
|
} else if let Some(_) = self.section_return {
|
|
|
|
return Err(self.ctm.err());
|
|
|
|
return Err(self.ctm.err());
|
|
|
|
} else if let Ok(pholder) = self.parse_placeholder() {
|
|
|
|
} else if let Ok(pholder) = self.parse_placeholder() {
|
|
|
@ -294,7 +299,7 @@ impl ParseBlock for Parser {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// parses an import and starts a new task to parse the document of the import
|
|
|
|
/// parses an import and starts a new task to parse the document of the import
|
|
|
|
fn parse_import(&mut self) -> ParseResult<Import> {
|
|
|
|
fn parse_import(&mut self) -> ParseResult<Option<Import>> {
|
|
|
|
let start_index = self.ctm.get_index();
|
|
|
|
let start_index = self.ctm.get_index();
|
|
|
|
self.ctm.seek_whitespace();
|
|
|
|
self.ctm.seek_whitespace();
|
|
|
|
self.ctm
|
|
|
|
self.ctm
|
|
|
@ -321,10 +326,13 @@ impl ParseBlock for Parser {
|
|
|
|
|
|
|
|
|
|
|
|
self.ctm.seek_whitespace();
|
|
|
|
self.ctm.seek_whitespace();
|
|
|
|
|
|
|
|
|
|
|
|
if let Ok(anchor) = self.import_document(path.clone()) {
|
|
|
|
match self.import(path.clone()) {
|
|
|
|
Ok(Import { path, anchor })
|
|
|
|
ImportType::Document(Ok(anchor)) => Ok(Some(Import { path, anchor })),
|
|
|
|
} else {
|
|
|
|
ImportType::Stylesheet(Ok(content)) => {
|
|
|
|
Err(self.ctm.err())
|
|
|
|
self.document.stylesheets.push(content);
|
|
|
|
|
|
|
|
Ok(None)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_ => Err(self.ctm.err()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|