diff --git a/src/elements/blockquote.rs b/src/elements/blockquote.rs index 48fd5c6..4afc8f7 100644 --- a/src/elements/blockquote.rs +++ b/src/elements/blockquote.rs @@ -22,8 +22,10 @@ use crate::compiler::compiler::Target; use crate::compiler::compiler::Target::HTML; use crate::document::document::Document; use crate::document::element::ContainerElement; +use crate::document::element::DocumentEnd; use crate::document::element::ElemKind; use crate::document::element::Element; +use crate::elements::paragraph::Paragraph; use crate::parser::parser::ParserState; use crate::parser::rule::Rule; use crate::parser::source::Cursor; @@ -31,7 +33,6 @@ use crate::parser::source::Source; use crate::parser::source::Token; use crate::parser::source::VirtualSource; use crate::parser::style::StyleHolder; -use crate::parser::util::parse_paragraph; use crate::parser::util::process_escaped; use crate::parser::util::Property; use crate::parser::util::PropertyParser; @@ -127,13 +128,36 @@ impl Element for Blockquote { result += format_author().map_err(|err| err.to_string())?.as_str(); } - result += "
";
+ let mut in_paragraph = false;
for elem in &self.content {
- result += elem
- .compile(compiler, document, cursor + result.len())?
- .as_str();
+ if elem.downcast_ref::().is_some()
+ {
+ if in_paragraph
+ {
+ result += "
"; + in_paragraph = true; + } + result += elem + .compile(compiler, document, cursor + result.len())? + .as_str(); + } } - result += "
"; + if in_paragraph + { + result += ""; + } + result += ""; if self.style.author_pos == After { result += format_author().map_err(|err| err.to_string())?.as_str(); } @@ -274,7 +298,6 @@ impl Rule for BlockquoteRule { // Content let entry_start = captures.get(0).unwrap().start(); let mut entry_content = captures.get(2).unwrap().as_str().to_string(); - let mut spacing: Option<(Range().is_some() + { + parsed_content.push(elem); + } + else + { reports.push( - Report::build(ReportKind::Warning, token.source(), token.range.start) + Report::build(ReportKind::Error, token.source(), token.range.start) .with_message("Unable to Parse Blockquote Entry") .with_label( Label::new((token.source(), token.range.clone())) - .with_message(err) - .with_color(state.parser.colors().warning), + .with_message("Blockquotes may only contain paragraphs and other blockquotes") + .with_color(state.parser.colors().error), ) .finish(), ); return (end_cursor, reports); } - Ok(mut paragraph) => std::mem::take(&mut paragraph.content), - }; + } // Get style let style = state @@ -431,6 +439,8 @@ BEFORE > ** AFTER > Another quote +>>[author=B] Nested +>>> More nested END "# .to_string(), @@ -448,12 +458,18 @@ END } { Text { content == "Some entry contin" }; Style; - Text { content == "ued here " }; + Text { content == "ued here" }; Style; }; Paragraph { Text{ content == "AFTER" }; }; Blockquote { Text { content == "Another quote" }; + Blockquote { author == Some("B".to_string()) } { + Text { content == "Nested" }; + Blockquote { + Text { content == "More nested" }; + }; + }; }; Paragraph { Text{ content == "END" }; }; );