diff --git a/src/document/document.rs b/src/document/document.rs
index 87f6e83..29a67b9 100644
--- a/src/document/document.rs
+++ b/src/document/document.rs
@@ -120,6 +120,7 @@ pub trait Document<'a>: core::fmt::Debug {
/// Pushes a new element into the document's content
fn push(&self, elem: Box) {
+ // Add reference
if let Some(refname) = elem
.as_referenceable()
.and_then(|reference| reference.reference_name())
@@ -128,7 +129,10 @@ pub trait Document<'a>: core::fmt::Debug {
refname.clone(),
ElemReference::Direct(self.content().borrow().len()),
);
- } else if let Some(container) = self
+ }
+ // Add contained references
+ else if let Some(container) =
+ self
.content()
.borrow()
.last()
diff --git a/src/document/variable.rs b/src/document/variable.rs
index 6460282..60611f6 100644
--- a/src/document/variable.rs
+++ b/src/document/variable.rs
@@ -7,7 +7,6 @@ use crate::parser::source::VirtualSource;
use std::path::PathBuf;
use std::rc::Rc;
-// TODO enforce to_string(from_string(to_string())) == to_string()
pub trait Variable {
fn location(&self) -> &Token;
diff --git a/src/elements/blockquote.rs b/src/elements/blockquote.rs
index 6b6af34..846e882 100644
--- a/src/elements/blockquote.rs
+++ b/src/elements/blockquote.rs
@@ -13,7 +13,6 @@ use blockquote_style::BlockquoteStyle;
use regex::Match;
use regex::Regex;
use runtime_format::FormatArgs;
-use runtime_format::FormatError;
use runtime_format::FormatKey;
use runtime_format::FormatKeyError;
@@ -22,7 +21,6 @@ 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;
@@ -127,8 +125,7 @@ impl Element for Blockquote {
let mut in_paragraph = false;
for elem in &self.content {
- if elem.downcast_ref::().is_some() {
- } else if elem.downcast_ref::().is_some() {
+ if elem.downcast_ref::().is_some() {
if in_paragraph {
result += "
";
in_paragraph = false;
diff --git a/src/elements/list.rs b/src/elements/list.rs
index 92b71c1..a431e08 100644
--- a/src/elements/list.rs
+++ b/src/elements/list.rs
@@ -396,11 +396,13 @@ impl Rule for ListRule {
)
.finish(),
);
- break;
+ // Return an empty paragraph
+ vec![]
}
Ok(mut paragraph) => std::mem::take(&mut paragraph.content),
};
+
if let Some(previous_depth) = document
.last_element::()
.map(|ent| ent.numbering.clone())
diff --git a/src/elements/script.rs b/src/elements/script.rs
index 8547639..b86be07 100644
--- a/src/elements/script.rs
+++ b/src/elements/script.rs
@@ -306,7 +306,7 @@ mod tests {
"".to_string(),
r#"
Simple evals:
- * %< 1+1>%
+ * 1+1: %< 1+1>%
* %<" 1+1>% = 2
* %%
@@ -327,7 +327,7 @@ Evaluation: %%
validate_document!(doc.content().borrow(), 0,
Paragraph;
ListMarker;
- ListEntry {};
+ ListEntry;
ListEntry {
Text { content == "2" };
Text { content == " = 2" };
diff --git a/src/parser/langparser.rs b/src/parser/langparser.rs
index 781c410..c748ac8 100644
--- a/src/parser/langparser.rs
+++ b/src/parser/langparser.rs
@@ -112,13 +112,16 @@ impl Parser for LangParser {
super::state::Scope::DOCUMENT,
));
- state.push(
- &doc,
- Box::new(DocumentEnd(Token::new(
- doc.source().content().len()..doc.source().content().len(),
- doc.source(),
- ))),
- );
+ if parent.is_none()
+ {
+ state.push(
+ &doc,
+ Box::new(DocumentEnd(Token::new(
+ doc.source().content().len()..doc.source().content().len(),
+ doc.source(),
+ ))),
+ );
+ }
(Box::new(doc), state)
}