Switch to getting the contents with a function to handle the escaped lines.
This commit is contained in:
parent
b56d847cfa
commit
afb43ff34f
@ -0,0 +1,10 @@
|
||||
#+begin_example
|
||||
,* foo
|
||||
,** bar
|
||||
,*** baz
|
||||
lorem
|
||||
, ipsum
|
||||
,#+begin_src dolar
|
||||
|
||||
,#+end_src
|
||||
#+end_example
|
@ -1549,11 +1549,12 @@ fn compare_example_block<'b, 's>(
|
||||
|
||||
// Compare value
|
||||
let contents = get_property_quoted_string(emacs, ":value")?.unwrap_or(String::new());
|
||||
if contents != rust.contents {
|
||||
let rust_contents = rust.get_contents();
|
||||
if contents != rust_contents {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
||||
contents, rust.contents
|
||||
contents, rust_contents
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -237,3 +237,25 @@ impl<'s> Comment<'s> {
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> ExampleBlock<'s> {
|
||||
/// Get the inner contents of the ExampleBlock with the escaping commas removed.
|
||||
pub fn get_contents(&self) -> String {
|
||||
let mut ret = String::with_capacity(self.contents.len());
|
||||
for line in self.contents.lines() {
|
||||
let first_comma = line.find(",#+").or_else(|| line.find(",*"));
|
||||
if let Some(first_comma) = first_comma {
|
||||
let before_first_comma = &line[..first_comma];
|
||||
let is_escaping_comma = before_first_comma.chars().all(char::is_whitespace);
|
||||
if is_escaping_comma {
|
||||
ret.push_str(&line[(first_comma + 1)..]);
|
||||
} else {
|
||||
ret.push_str(line);
|
||||
}
|
||||
} else {
|
||||
ret.push_str(line);
|
||||
}
|
||||
}
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user