Compare commits
7 Commits
eaa38ce772
...
d82def2a70
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d82def2a70 | ||
![]() |
d471f7178b | ||
![]() |
2c5c26c55f | ||
![]() |
7944659802 | ||
![]() |
58aca53144 | ||
![]() |
6f2d90162b | ||
![]() |
f170a557ed |
1
build.rs
1
build.rs
@ -75,6 +75,7 @@ fn is_expect_fail(name: &str) -> Option<&str> {
|
||||
"autogen_greater_element_drawer_drawer_with_headline_inside" => Some("Apparently lines with :end: become their own paragraph. This odd behavior needs to be investigated more."),
|
||||
"autogen_element_container_priority_footnote_definition_dynamic_block" => Some("Apparently broken begin lines become their own paragraph."),
|
||||
"autogen_lesser_element_paragraphs_paragraph_with_backslash_line_breaks" => Some("The text we're getting out of the parse tree is already processed to remove line breaks, so our comparison needs to take that into account."),
|
||||
"autogen_unicode_hearts" => Some("Unicode is coming out of emacs strange."),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
** foo
|
||||
:PROPERTIES:
|
||||
:DESCRIPTION: lorem
|
||||
:ALT_TITLE: ipsum
|
||||
:END:
|
||||
|
||||
bar
|
1
org_mode_samples/unicode/hearts.org
Normal file
1
org_mode_samples/unicode/hearts.org
Normal file
@ -0,0 +1 @@
|
||||
🧡💛💚💙💜
|
File diff suppressed because it is too large
Load Diff
@ -51,7 +51,7 @@ pub fn assert_bounds<'s, S: Source<'s>>(
|
||||
);
|
||||
let (rust_begin, rust_end) = get_offsets(source, rust);
|
||||
if (rust_begin + 1) != begin || (rust_end + 1) != end {
|
||||
Err(format!("Rust bounds ({rust_begin}, {rust_end}) do not match emacs bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin + 1, rust_end = rust_end + 1, emacs_begin=begin, emacs_end=end))?;
|
||||
Err(format!("Rust bounds (in bytes) ({rust_begin}, {rust_end}) do not match emacs bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin + 1, rust_end = rust_end + 1, emacs_begin=begin, emacs_end=end))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -137,3 +137,23 @@ fn maybe_token_to_usize(
|
||||
.flatten() // Outer option is whether or not the param exists, inner option is whether or not it is nil
|
||||
.map_or(Ok(None), |r| r.map(Some))?)
|
||||
}
|
||||
|
||||
pub fn get_property<'s, 'x>(
|
||||
emacs: &'s Token<'s>,
|
||||
key: &'x str,
|
||||
) -> Result<Option<&'s Token<'s>>, Box<dyn std::error::Error>> {
|
||||
let children = emacs.as_list()?;
|
||||
let attributes_child = children
|
||||
.iter()
|
||||
.nth(1)
|
||||
.ok_or("Should have an attributes child.")?;
|
||||
let attributes_map = attributes_child.as_map()?;
|
||||
let prop = attributes_map
|
||||
.get(key)
|
||||
.ok_or(format!("Missing {} attribute.", key))?;
|
||||
match prop.as_atom() {
|
||||
Ok("nil") => return Ok(None),
|
||||
_ => {}
|
||||
};
|
||||
Ok(Some(*prop))
|
||||
}
|
||||
|
@ -2,13 +2,14 @@ use nom::branch::alt;
|
||||
use nom::bytes::complete::is_not;
|
||||
use nom::bytes::complete::tag;
|
||||
use nom::bytes::complete::tag_no_case;
|
||||
use nom::character::complete::anychar;
|
||||
use nom::character::complete::line_ending;
|
||||
use nom::character::complete::space0;
|
||||
use nom::character::complete::space1;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::opt;
|
||||
use nom::combinator::recognize;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
@ -23,7 +24,6 @@ use crate::parser::greater_element::PropertyDrawer;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
use crate::parser::parser_context::ExitMatcherNode;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
use crate::parser::plain_text::plain_text;
|
||||
use crate::parser::util::exit_matcher_parser;
|
||||
use crate::parser::util::get_consumed;
|
||||
use crate::parser::util::immediate_in_section;
|
||||
@ -147,11 +147,16 @@ fn node_property_name<'r, 's>(
|
||||
}));
|
||||
|
||||
let (remaining, name) = recognize(tuple((
|
||||
map(parser_with_context!(plain_text)(&parser_context), |pt| {
|
||||
pt.source
|
||||
}),
|
||||
verify(
|
||||
many_till(
|
||||
anychar,
|
||||
parser_with_context!(exit_matcher_parser)(&parser_context),
|
||||
),
|
||||
|(children, _exit_contents)| !children.is_empty(),
|
||||
),
|
||||
opt(tag("+")),
|
||||
)))(input)?;
|
||||
|
||||
Ok((remaining, name))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user