Compare export type.
This commit is contained in:
parent
1da521b08a
commit
58ca9569a6
@ -1845,9 +1845,19 @@ fn compare_export_block<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// TODO: Compare :type
|
||||
// TODO: Compare :caption
|
||||
|
||||
// Compare type
|
||||
let export_type = get_property_quoted_string(emacs, ":type")?;
|
||||
let rust_export_type = rust.get_export_type();
|
||||
if export_type != rust_export_type {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Export type mismatch (emacs != rust) {:?} != {:?}",
|
||||
export_type, rust.export_type
|
||||
));
|
||||
}
|
||||
|
||||
// Compare value
|
||||
let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
|
||||
if contents != rust.contents {
|
||||
|
@ -208,6 +208,9 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
|
||||
let (input, affiliated_keywords) = many0(affiliated_keyword)(input)?;
|
||||
let (remaining, _) = lesser_block_begin("export")(context, input)?;
|
||||
// https://orgmode.org/worg/org-syntax.html#Blocks claims that export blocks must have a single word for data but testing shows no data and multi-word data still parses as an export block.
|
||||
let (remaining, export_type) = opt(map(tuple((space1, switch_word)), |(_, export_type)| {
|
||||
export_type
|
||||
}))(remaining)?;
|
||||
let (remaining, parameters) = opt(tuple((space1, data)))(remaining)?;
|
||||
let (remaining, _nl) = recognize(tuple((space0, line_ending)))(remaining)?;
|
||||
let lesser_block_end_specialized = lesser_block_end("export");
|
||||
@ -236,6 +239,7 @@ pub(crate) fn export_block<'b, 'g, 'r, 's>(
|
||||
ExportBlock {
|
||||
source: source.into(),
|
||||
name: get_name(&affiliated_keywords),
|
||||
export_type: export_type.map(Into::<&str>::into),
|
||||
data: parameters.map(|parameters| Into::<&str>::into(parameters)),
|
||||
contents,
|
||||
},
|
||||
|
@ -64,6 +64,7 @@ pub struct ExampleBlock<'s> {
|
||||
pub struct ExportBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: Option<&'s str>,
|
||||
pub export_type: Option<&'s str>,
|
||||
pub data: Option<&'s str>,
|
||||
pub contents: String,
|
||||
}
|
||||
@ -266,3 +267,9 @@ impl<'s> Comment<'s> {
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> ExportBlock<'s> {
|
||||
pub fn get_export_type(&self) -> Option<String> {
|
||||
self.export_type.map(|s| s.to_uppercase())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user