Add check for name on paragraph.
This commit is contained in:
parent
057c8a1387
commit
a26640355c
2
org_mode_samples/lesser_element/paragraph/name.org
Normal file
2
org_mode_samples/lesser_element/paragraph/name.org
Normal file
@ -0,0 +1,2 @@
|
||||
#+NAME: foo
|
||||
bar
|
@ -841,8 +841,18 @@ fn compare_paragraph<'b, 's>(
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let children = emacs.as_list()?;
|
||||
let mut child_status = Vec::new();
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||
|
@ -1,6 +1,8 @@
|
||||
use nom::branch::alt;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::not;
|
||||
use nom::multi::many0;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
use super::clock::clock;
|
||||
use super::comment::comment;
|
||||
@ -98,7 +100,13 @@ fn _element<'b, 'g, 'r, 's>(
|
||||
map(horizontal_rule_matcher, Element::HorizontalRule),
|
||||
map(latex_environment_matcher, Element::LatexEnvironment),
|
||||
map(babel_keyword_matcher, Element::BabelCall),
|
||||
map(keyword_matcher, Element::Keyword),
|
||||
map(
|
||||
map(
|
||||
tuple((not(affiliated_keyword_matcher), keyword_matcher)),
|
||||
|(_, kw)| kw,
|
||||
),
|
||||
Element::Keyword,
|
||||
),
|
||||
))(remaining)
|
||||
{
|
||||
the_ok @ Ok(_) => the_ok,
|
||||
|
@ -47,6 +47,7 @@ pub(crate) fn paragraph<'b, 'g, 'r, 's>(
|
||||
remaining,
|
||||
Paragraph {
|
||||
source: source.into(),
|
||||
name: None, // TODO
|
||||
children,
|
||||
},
|
||||
))
|
||||
|
@ -6,6 +6,7 @@ use super::Timestamp;
|
||||
#[derive(Debug)]
|
||||
pub struct Paragraph<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: Option<&'s str>,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
@ -146,6 +147,7 @@ impl<'s> Paragraph<'s> {
|
||||
objects.push(Object::PlainText(PlainText { source: input }));
|
||||
Paragraph {
|
||||
source: input,
|
||||
name: None, // TODO
|
||||
children: objects,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user