Move the affiliated keywords parser inside the specific element parsers.
We need access to the affiliated keywords to do things like set the name of the element, and only half the element parsers are allowed to have affiliated keywords, so it makes sense to move it inside the specific parsers.
This commit is contained in:
parent
a26640355c
commit
d8102b7bc2
10
org_mode_samples/greater_element/drawer/name.org
Normal file
10
org_mode_samples/greater_element/drawer/name.org
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
* Headline
|
||||||
|
before
|
||||||
|
#+NAME: foo
|
||||||
|
:candle:
|
||||||
|
inside
|
||||||
|
|
||||||
|
the drawer
|
||||||
|
:end:
|
||||||
|
|
||||||
|
after
|
7
org_mode_samples/greater_element/dynamic_block/name.org
Normal file
7
org_mode_samples/greater_element/dynamic_block/name.org
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
#+BEGIN: clocktable :scope file :maxlevel 2
|
||||||
|
#+CAPTION: Clock summary at [2023-08-25 Fri 05:34]
|
||||||
|
| Headline | Time |
|
||||||
|
|--------------+--------|
|
||||||
|
| *Total time* | *0:00* |
|
||||||
|
#+END:
|
@ -0,0 +1,4 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
#+begin_center
|
||||||
|
|
||||||
|
#+end_center
|
@ -0,0 +1,4 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
#+begin_quote
|
||||||
|
|
||||||
|
#+end_quote
|
@ -0,0 +1,6 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
#+begin_defun
|
||||||
|
foo
|
||||||
|
|
||||||
|
{{{bar(baz)}}}
|
||||||
|
#+end_defun
|
2
org_mode_samples/greater_element/plain_list/name.org
Normal file
2
org_mode_samples/greater_element/plain_list/name.org
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
1. bar
|
2
org_mode_samples/lesser_element/babel_call/name.org
Normal file
2
org_mode_samples/lesser_element/babel_call/name.org
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
#+call: foo(bar="baz")
|
3
org_mode_samples/lesser_element/clock/name.org
Normal file
3
org_mode_samples/lesser_element/clock/name.org
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
CLOCK: [2023-04-21 Fri 19:32]--[2023-04-21 Fri 19:35] => 0:03
|
||||||
|
#+NAME: foo
|
||||||
|
CLOCK: [2023-04-21 Fri 19:43]
|
2
org_mode_samples/lesser_element/comment/name.org
Normal file
2
org_mode_samples/lesser_element/comment/name.org
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
# Comments cannot have affiliated keywords.
|
2
org_mode_samples/lesser_element/diary_sexp/name.org
Normal file
2
org_mode_samples/lesser_element/diary_sexp/name.org
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
%%(foo)
|
@ -0,0 +1,2 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
: bar
|
2
org_mode_samples/lesser_element/horizontal_rule/name.org
Normal file
2
org_mode_samples/lesser_element/horizontal_rule/name.org
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
-----
|
2
org_mode_samples/lesser_element/keyword/name.org
Normal file
2
org_mode_samples/lesser_element/keyword/name.org
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
#+FOO: BAR
|
@ -0,0 +1,4 @@
|
|||||||
|
#+NAME: foo
|
||||||
|
\begin{foo}
|
||||||
|
bar
|
||||||
|
\end{foo}
|
@ -879,6 +879,16 @@ fn compare_plain_list<'b, 's>(
|
|||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let mut message = None;
|
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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// Compare type
|
// Compare type
|
||||||
// :type is an unquoted atom of either descriptive, ordered, or unordered
|
// :type is an unquoted atom of either descriptive, ordered, or unordered
|
||||||
let list_type = get_property_unquoted_atom(emacs, ":type")?;
|
let list_type = get_property_unquoted_atom(emacs, ":type")?;
|
||||||
@ -1037,8 +1047,18 @@ fn compare_center_block<'b, 's>(
|
|||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
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()) {
|
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())?);
|
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||||
@ -1062,8 +1082,18 @@ fn compare_quote_block<'b, 's>(
|
|||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let children = emacs.as_list()?;
|
let children = emacs.as_list()?;
|
||||||
let mut child_status = Vec::new();
|
let mut child_status = Vec::new();
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
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()) {
|
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())?);
|
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||||
@ -1090,14 +1120,24 @@ fn compare_special_block<'b, 's>(
|
|||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// Compare type
|
// Compare name
|
||||||
let special_block_type =
|
let name = get_property_quoted_string(emacs, ":name")?;
|
||||||
get_property_quoted_string(emacs, ":type")?.ok_or("Special blocks should have a name.")?;
|
if name.as_ref().map(String::as_str) != rust.name {
|
||||||
if special_block_type != rust.name {
|
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
message = Some(format!(
|
message = Some(format!(
|
||||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||||
special_block_type, rust.name
|
name, rust.name
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare type
|
||||||
|
let special_block_type =
|
||||||
|
get_property_quoted_string(emacs, ":type")?.ok_or("Special blocks should have a name.")?;
|
||||||
|
if special_block_type != rust.block_type {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
special_block_type, rust.block_type
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,14 +1180,24 @@ fn compare_dynamic_block<'b, 's>(
|
|||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// Compare block-name
|
// Compare name
|
||||||
let block_name = get_property_quoted_string(emacs, ":block-name")?
|
let name = get_property_quoted_string(emacs, ":name")?;
|
||||||
.ok_or("Dynamic blocks should have a name.")?;
|
if name.as_ref().map(String::as_str) != rust.name {
|
||||||
if block_name != rust.name {
|
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
message = Some(format!(
|
message = Some(format!(
|
||||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||||
block_name, rust.name
|
name, rust.name
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare block-name
|
||||||
|
let block_name = get_property_quoted_string(emacs, ":block-name")?
|
||||||
|
.ok_or("Dynamic blocks should have a name.")?;
|
||||||
|
if block_name != rust.block_name {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
block_name, rust.block_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1191,6 +1241,16 @@ fn compare_footnote_definition<'b, 's>(
|
|||||||
let mut message = None;
|
let mut message = None;
|
||||||
// TODO: Compare :pre-blank
|
// TODO: Compare :pre-blank
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// Compare label
|
// Compare label
|
||||||
let label = get_property_quoted_string(emacs, ":label")?
|
let label = get_property_quoted_string(emacs, ":label")?
|
||||||
.ok_or("Footnote definitions should have a name.")?;
|
.ok_or("Footnote definitions should have a name.")?;
|
||||||
@ -1259,10 +1319,9 @@ fn compare_drawer<'b, 's>(
|
|||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// Compare drawer-name
|
// Compare name
|
||||||
let name =
|
let name = get_property_quoted_string(emacs, ":name")?;
|
||||||
get_property_quoted_string(emacs, ":drawer-name")?.ok_or("Drawers should have a name.")?;
|
if name.as_ref().map(String::as_str) != rust.name {
|
||||||
if name != rust.name {
|
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
message = Some(format!(
|
message = Some(format!(
|
||||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||||
@ -1270,6 +1329,17 @@ fn compare_drawer<'b, 's>(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compare drawer-name
|
||||||
|
let drawer_name =
|
||||||
|
get_property_quoted_string(emacs, ":drawer-name")?.ok_or("Drawers should have a name.")?;
|
||||||
|
if drawer_name != rust.drawer_name {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
message = Some(format!(
|
||||||
|
"Drawer name mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
drawer_name, rust.drawer_name
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
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())?);
|
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||||
}
|
}
|
||||||
@ -1322,11 +1392,11 @@ fn compare_node_property<'b, 's>(
|
|||||||
// Compare key
|
// Compare key
|
||||||
let key =
|
let key =
|
||||||
get_property_quoted_string(emacs, ":key")?.ok_or("Node properties should have a key.")?;
|
get_property_quoted_string(emacs, ":key")?.ok_or("Node properties should have a key.")?;
|
||||||
if key != rust.name {
|
if key != rust.property_name {
|
||||||
this_status = DiffStatus::Bad;
|
this_status = DiffStatus::Bad;
|
||||||
message = Some(format!(
|
message = Some(format!(
|
||||||
"Key mismatch (emacs != rust) {:?} != {:?}",
|
"Key mismatch (emacs != rust) {:?} != {:?}",
|
||||||
key, rust.name
|
key, rust.property_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1365,6 +1435,16 @@ fn compare_table<'b, 's>(
|
|||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let mut message = None;
|
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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// Compare formulas
|
// Compare formulas
|
||||||
//
|
//
|
||||||
// :tblfm is either nil or a list () filled with quoted strings containing the value for any tblfm keywords at the end of the table.
|
// :tblfm is either nil or a list () filled with quoted strings containing the value for any tblfm keywords at the end of the table.
|
||||||
@ -2004,11 +2084,21 @@ fn compare_diary_sexp<'b, 's>(
|
|||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b DiarySexp<'s>,
|
rust: &'b DiarySexp<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :value
|
// TODO: Compare :value
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
@ -2097,11 +2187,21 @@ fn compare_fixed_width_area<'b, 's>(
|
|||||||
rust: &'b FixedWidthArea<'s>,
|
rust: &'b FixedWidthArea<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let child_status = Vec::new();
|
let child_status = Vec::new();
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :value
|
// TODO: Compare :value
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
@ -2119,8 +2219,18 @@ fn compare_horizontal_rule<'b, 's>(
|
|||||||
rust: &'b HorizontalRule<'s>,
|
rust: &'b HorizontalRule<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let child_status = Vec::new();
|
let child_status = Vec::new();
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
@ -2142,6 +2252,16 @@ fn compare_keyword<'b, 's>(
|
|||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let mut message = None;
|
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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let key = unquote(
|
let key = unquote(
|
||||||
get_property(emacs, ":key")?
|
get_property(emacs, ":key")?
|
||||||
.ok_or("Emacs keywords should have a :key")?
|
.ok_or("Emacs keywords should have a :key")?
|
||||||
@ -2188,6 +2308,17 @@ fn compare_babel_call<'b, 's>(
|
|||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :call :inside-header :arguments :end-header
|
// TODO: Compare :call :inside-header :arguments :end-header
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
let value = unquote(
|
let value = unquote(
|
||||||
get_property(emacs, ":value")?
|
get_property(emacs, ":value")?
|
||||||
.ok_or("Emacs keywords should have a :value")?
|
.ok_or("Emacs keywords should have a :value")?
|
||||||
@ -2218,11 +2349,21 @@ fn compare_latex_environment<'b, 's>(
|
|||||||
rust: &'b LatexEnvironment<'s>,
|
rust: &'b LatexEnvironment<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let child_status = Vec::new();
|
let child_status = Vec::new();
|
||||||
let this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
let message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// TODO: Compare :value
|
// TODO: Compare :value
|
||||||
|
|
||||||
|
// 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
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
|
@ -3,9 +3,12 @@ use nom::bytes::complete::is_not;
|
|||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::line_ending;
|
use nom::character::complete::line_ending;
|
||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
|
use crate::context::parser_with_context;
|
||||||
use crate::context::RefContext;
|
use crate::context::RefContext;
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
@ -14,9 +17,11 @@ use crate::types::DiarySexp;
|
|||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn diary_sexp<'b, 'g, 'r, 's>(
|
pub(crate) fn diary_sexp<'b, 'g, 'r, 's>(
|
||||||
_context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, DiarySexp<'s>> {
|
) -> Res<OrgSource<'s>, DiarySexp<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _clock) = tag("%%(")(input)?;
|
let (remaining, _clock) = tag("%%(")(input)?;
|
||||||
let (remaining, _contents) = is_not("\r\n")(remaining)?;
|
let (remaining, _contents) = is_not("\r\n")(remaining)?;
|
||||||
@ -27,6 +32,7 @@ pub(crate) fn diary_sexp<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
DiarySexp {
|
DiarySexp {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
name: None, // TODO
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@ use nom::character::complete::space0;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::not;
|
use nom::combinator::not;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
use crate::context::ContextElement;
|
use crate::context::ContextElement;
|
||||||
@ -41,6 +43,8 @@ pub(crate) fn drawer<'b, 'g, 'r, 's>(
|
|||||||
"Cannot nest objects of the same element".into(),
|
"Cannot nest objects of the same element".into(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, (_open_colon, drawer_name, _close_colon, _new_line)) = tuple((
|
let (remaining, (_open_colon, drawer_name, _close_colon, _new_line)) = tuple((
|
||||||
@ -90,7 +94,8 @@ pub(crate) fn drawer<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Drawer {
|
Drawer {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
name: drawer_name.into(),
|
name: None, // TODO
|
||||||
|
drawer_name: drawer_name.into(),
|
||||||
children,
|
children,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
@ -17,6 +17,7 @@ use nom::multi::many_till;
|
|||||||
use nom::sequence::preceded;
|
use nom::sequence::preceded;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
use crate::context::ContextElement;
|
use crate::context::ContextElement;
|
||||||
@ -47,6 +48,9 @@ pub(crate) fn dynamic_block<'b, 'g, 'r, 's>(
|
|||||||
"Cannot nest objects of the same element".into(),
|
"Cannot nest objects of the same element".into(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
|
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, (_, name, parameters, _, _)) = tuple((
|
let (remaining, (_, name, parameters, _, _)) = tuple((
|
||||||
@ -97,7 +101,8 @@ pub(crate) fn dynamic_block<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
DynamicBlock {
|
DynamicBlock {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
name: name.into(),
|
name: None, // TODO
|
||||||
|
block_name: name.into(),
|
||||||
parameters: parameters.map(|val| val.into()),
|
parameters: parameters.map(|val| val.into()),
|
||||||
children,
|
children,
|
||||||
},
|
},
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
use nom::combinator::map;
|
use nom::combinator::map;
|
||||||
use nom::combinator::not;
|
|
||||||
use nom::multi::many0;
|
|
||||||
use nom::sequence::tuple;
|
|
||||||
|
|
||||||
use super::clock::clock;
|
use super::clock::clock;
|
||||||
use super::comment::comment;
|
use super::comment::comment;
|
||||||
@ -79,8 +76,6 @@ fn _element<'b, 'g, 'r, 's>(
|
|||||||
let paragraph_matcher = parser_with_context!(paragraph)(context);
|
let paragraph_matcher = parser_with_context!(paragraph)(context);
|
||||||
let latex_environment_matcher = parser_with_context!(latex_environment)(context);
|
let latex_environment_matcher = parser_with_context!(latex_environment)(context);
|
||||||
|
|
||||||
// TODO: Affiliated keywords cannot be on comments, clocks, headings, inlinetasks, items, node properties, planning, property drawers, sections, and table rows
|
|
||||||
let (remaining, mut affiliated_keywords) = many0(affiliated_keyword_matcher)(input)?;
|
|
||||||
let (remaining, mut element) = match alt((
|
let (remaining, mut element) = match alt((
|
||||||
map(plain_list_matcher, Element::PlainList),
|
map(plain_list_matcher, Element::PlainList),
|
||||||
greater_block_matcher,
|
greater_block_matcher,
|
||||||
@ -100,28 +95,20 @@ fn _element<'b, 'g, 'r, 's>(
|
|||||||
map(horizontal_rule_matcher, Element::HorizontalRule),
|
map(horizontal_rule_matcher, Element::HorizontalRule),
|
||||||
map(latex_environment_matcher, Element::LatexEnvironment),
|
map(latex_environment_matcher, Element::LatexEnvironment),
|
||||||
map(babel_keyword_matcher, Element::BabelCall),
|
map(babel_keyword_matcher, Element::BabelCall),
|
||||||
map(
|
map(keyword_matcher, Element::Keyword),
|
||||||
map(
|
))(input)
|
||||||
tuple((not(affiliated_keyword_matcher), keyword_matcher)),
|
|
||||||
|(_, kw)| kw,
|
|
||||||
),
|
|
||||||
Element::Keyword,
|
|
||||||
),
|
|
||||||
))(remaining)
|
|
||||||
{
|
{
|
||||||
the_ok @ Ok(_) => the_ok,
|
the_ok @ Ok(_) => the_ok,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
if can_be_paragraph {
|
if can_be_paragraph {
|
||||||
match map(paragraph_matcher, Element::Paragraph)(remaining) {
|
match map(paragraph_matcher, Element::Paragraph)(input) {
|
||||||
the_ok @ Ok(_) => the_ok,
|
the_ok @ Ok(_) => the_ok,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// TODO: Because this function expects a single element, if there are multiple affiliated keywords before an element that cannot have affiliated keywords, we end up re-parsing the affiliated keywords many times.
|
// TODO: Because this function expects a single element, if there are multiple affiliated keywords before an element that cannot have affiliated keywords, we end up re-parsing the affiliated keywords many times.
|
||||||
affiliated_keywords.clear();
|
|
||||||
map(affiliated_keyword_matcher, Element::Keyword)(input)
|
map(affiliated_keyword_matcher, Element::Keyword)(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
affiliated_keywords.clear();
|
|
||||||
map(affiliated_keyword_matcher, Element::Keyword)(input)
|
map(affiliated_keyword_matcher, Element::Keyword)(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,6 +136,7 @@ fn _detect_element<'b, 'g, 'r, 's>(
|
|||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
can_be_paragraph: bool,
|
can_be_paragraph: bool,
|
||||||
) -> Res<OrgSource<'s>, ()> {
|
) -> Res<OrgSource<'s>, ()> {
|
||||||
|
// TODO: What about affiliated keywords in the detect_* functions?
|
||||||
if alt((
|
if alt((
|
||||||
parser_with_context!(detect_plain_list)(context),
|
parser_with_context!(detect_plain_list)(context),
|
||||||
detect_footnote_definition,
|
detect_footnote_definition,
|
||||||
|
@ -10,6 +10,7 @@ use nom::multi::many0;
|
|||||||
use nom::sequence::preceded;
|
use nom::sequence::preceded;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::only_space1;
|
use super::util::only_space1;
|
||||||
use super::util::org_line_ending;
|
use super::util::org_line_ending;
|
||||||
@ -26,6 +27,8 @@ pub(crate) fn fixed_width_area<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, FixedWidthArea<'s>> {
|
) -> Res<OrgSource<'s>, FixedWidthArea<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
let fixed_width_area_line_matcher = parser_with_context!(fixed_width_area_line)(context);
|
let fixed_width_area_line_matcher = parser_with_context!(fixed_width_area_line)(context);
|
||||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(context);
|
let exit_matcher = parser_with_context!(exit_matcher_parser)(context);
|
||||||
let (remaining, _first_line) = fixed_width_area_line_matcher(input)?;
|
let (remaining, _first_line) = fixed_width_area_line_matcher(input)?;
|
||||||
@ -37,6 +40,7 @@ pub(crate) fn fixed_width_area<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
FixedWidthArea {
|
FixedWidthArea {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
name: None, // TODO
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ use nom::multi::many1;
|
|||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::include_input;
|
use super::util::include_input;
|
||||||
use super::util::WORD_CONSTITUENT_CHARACTERS;
|
use super::util::WORD_CONSTITUENT_CHARACTERS;
|
||||||
@ -41,6 +42,8 @@ pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
|
|||||||
"Cannot nest objects of the same element".into(),
|
"Cannot nest objects of the same element".into(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
// Cannot be indented.
|
// Cannot be indented.
|
||||||
let (remaining, (_, lbl, _, _, _)) = tuple((
|
let (remaining, (_, lbl, _, _, _)) = tuple((
|
||||||
@ -85,6 +88,7 @@ pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
FootnoteDefinition {
|
FootnoteDefinition {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
name: None, // TODO
|
||||||
label: lbl.into(),
|
label: lbl.into(),
|
||||||
children: children.into_iter().map(|(_, item)| item).collect(),
|
children: children.into_iter().map(|(_, item)| item).collect(),
|
||||||
},
|
},
|
||||||
|
@ -17,6 +17,7 @@ use nom::multi::many_till;
|
|||||||
use nom::sequence::preceded;
|
use nom::sequence::preceded;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::in_section;
|
use super::util::in_section;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
@ -45,6 +46,8 @@ pub(crate) fn greater_block<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Element<'s>> {
|
) -> Res<OrgSource<'s>, Element<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, (_begin, name)) = tuple((
|
let (remaining, (_begin, name)) = tuple((
|
||||||
@ -75,7 +78,11 @@ fn center_block<'b, 'g, 'r, 's>(
|
|||||||
greater_block_body(context, input, original_input, "center", "center block")?;
|
greater_block_body(context, input, original_input, "center", "center block")?;
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
Element::CenterBlock(CenterBlock { source, children }),
|
Element::CenterBlock(CenterBlock {
|
||||||
|
source,
|
||||||
|
name: None, // TODO
|
||||||
|
children,
|
||||||
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +96,11 @@ fn quote_block<'b, 'g, 'r, 's>(
|
|||||||
greater_block_body(context, input, original_input, "quote", "quote block")?;
|
greater_block_body(context, input, original_input, "quote", "quote block")?;
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
Element::QuoteBlock(QuoteBlock { source, children }),
|
Element::QuoteBlock(QuoteBlock {
|
||||||
|
source,
|
||||||
|
name: None, // TODO
|
||||||
|
children,
|
||||||
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +133,9 @@ fn _special_block<'c, 'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Element::SpecialBlock(SpecialBlock {
|
Element::SpecialBlock(SpecialBlock {
|
||||||
source,
|
source,
|
||||||
|
name: None, // TODO
|
||||||
children,
|
children,
|
||||||
name,
|
block_type: name,
|
||||||
parameters: parameters.map(|(_, parameters)| Into::<&str>::into(parameters)),
|
parameters: parameters.map(|(_, parameters)| Into::<&str>::into(parameters)),
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
|
@ -5,10 +5,13 @@ use nom::character::complete::space0;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many1_count;
|
use nom::multi::many1_count;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
|
use crate::context::parser_with_context;
|
||||||
use crate::context::RefContext;
|
use crate::context::RefContext;
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
@ -16,9 +19,11 @@ use crate::types::HorizontalRule;
|
|||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn horizontal_rule<'b, 'g, 'r, 's>(
|
pub(crate) fn horizontal_rule<'b, 'g, 'r, 's>(
|
||||||
_context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, HorizontalRule<'s>> {
|
) -> Res<OrgSource<'s>, HorizontalRule<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, rule) = recognize(tuple((
|
let (remaining, rule) = recognize(tuple((
|
||||||
space0,
|
space0,
|
||||||
@ -30,6 +35,7 @@ pub(crate) fn horizontal_rule<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
HorizontalRule {
|
HorizontalRule {
|
||||||
source: rule.into(),
|
source: rule.into(),
|
||||||
|
name: None, // TODO
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,13 @@ use nom::combinator::not;
|
|||||||
use nom::combinator::peek;
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::org_source::BracketDepth;
|
use super::org_source::BracketDepth;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
|
use crate::context::parser_with_context;
|
||||||
use crate::context::Matcher;
|
use crate::context::Matcher;
|
||||||
use crate::context::RefContext;
|
use crate::context::RefContext;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
@ -61,6 +63,7 @@ fn _filtered_keyword<'s, F: Matcher>(
|
|||||||
remaining,
|
remaining,
|
||||||
Keyword {
|
Keyword {
|
||||||
source: consumed_input.into(),
|
source: consumed_input.into(),
|
||||||
|
name: None, // TODO
|
||||||
key: parsed_key.into(),
|
key: parsed_key.into(),
|
||||||
value: "".into(),
|
value: "".into(),
|
||||||
},
|
},
|
||||||
@ -78,6 +81,7 @@ fn _filtered_keyword<'s, F: Matcher>(
|
|||||||
remaining,
|
remaining,
|
||||||
Keyword {
|
Keyword {
|
||||||
source: consumed_input.into(),
|
source: consumed_input.into(),
|
||||||
|
name: None, // TODO
|
||||||
key: parsed_key.into(),
|
key: parsed_key.into(),
|
||||||
value: parsed_value.into(),
|
value: parsed_value.into(),
|
||||||
},
|
},
|
||||||
@ -86,9 +90,11 @@ fn _filtered_keyword<'s, F: Matcher>(
|
|||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn keyword<'b, 'g, 'r, 's>(
|
pub(crate) fn keyword<'b, 'g, 'r, 's>(
|
||||||
_context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Keyword<'s>> {
|
) -> Res<OrgSource<'s>, Keyword<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
filtered_keyword(regular_keyword_key)(input)
|
filtered_keyword(regular_keyword_key)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,14 +108,17 @@ pub(crate) fn affiliated_keyword<'b, 'g, 'r, 's>(
|
|||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn babel_call_keyword<'b, 'g, 'r, 's>(
|
pub(crate) fn babel_call_keyword<'b, 'g, 'r, 's>(
|
||||||
_context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, BabelCall<'s>> {
|
) -> Res<OrgSource<'s>, BabelCall<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
let (remaining, kw) = filtered_keyword(babel_call_key)(input)?;
|
let (remaining, kw) = filtered_keyword(babel_call_key)(input)?;
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
BabelCall {
|
BabelCall {
|
||||||
source: kw.source,
|
source: kw.source,
|
||||||
|
name: None, // TODO
|
||||||
key: kw.key,
|
key: kw.key,
|
||||||
value: kw.value,
|
value: kw.value,
|
||||||
},
|
},
|
||||||
|
@ -8,9 +8,11 @@ use nom::character::complete::space0;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::peek;
|
use nom::combinator::peek;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::get_consumed;
|
use super::util::get_consumed;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
@ -29,6 +31,8 @@ pub(crate) fn latex_environment<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, LatexEnvironment<'s>> {
|
) -> Res<OrgSource<'s>, LatexEnvironment<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, (_opening, name, _open_close_brace, _ws, _line_ending)) = tuple((
|
let (remaining, (_opening, name, _open_close_brace, _ws, _line_ending)) = tuple((
|
||||||
@ -54,6 +58,7 @@ pub(crate) fn latex_environment<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
LatexEnvironment {
|
LatexEnvironment {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
name: None, // TODO
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,13 @@ use nom::branch::alt;
|
|||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
|
use nom::multi::many0;
|
||||||
use nom::multi::many1;
|
use nom::multi::many1;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::element_parser::detect_element;
|
use super::element_parser::detect_element;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::blank_line;
|
use super::util::blank_line;
|
||||||
use super::util::get_consumed;
|
use super::util::get_consumed;
|
||||||
@ -26,6 +28,9 @@ pub(crate) fn paragraph<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Paragraph<'s>> {
|
) -> Res<OrgSource<'s>, Paragraph<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
|
|
||||||
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
class: ExitClass::Gamma,
|
class: ExitClass::Gamma,
|
||||||
exit_matcher: ¶graph_end,
|
exit_matcher: ¶graph_end,
|
||||||
|
@ -19,6 +19,7 @@ use nom::multi::many_till;
|
|||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::element_parser::element;
|
use super::element_parser::element;
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::object_parser::standard_set_object;
|
use super::object_parser::standard_set_object;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::include_input;
|
use super::util::include_input;
|
||||||
@ -78,6 +79,9 @@ pub(crate) fn plain_list<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, PlainList<'s>> {
|
) -> Res<OrgSource<'s>, PlainList<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
|
|
||||||
let contexts = [
|
let contexts = [
|
||||||
ContextElement::Context("plain list"),
|
ContextElement::Context("plain list"),
|
||||||
ContextElement::ConsumeTrailingWhitespace(true),
|
ContextElement::ConsumeTrailingWhitespace(true),
|
||||||
@ -150,6 +154,7 @@ pub(crate) fn plain_list<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
PlainList {
|
PlainList {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
name: None, // TODO
|
||||||
list_type: first_item_list_type.expect("Plain lists require at least one element."),
|
list_type: first_item_list_type.expect("Plain lists require at least one element."),
|
||||||
children: children.into_iter().map(|(_start, item)| item).collect(),
|
children: children.into_iter().map(|(_start, item)| item).collect(),
|
||||||
},
|
},
|
||||||
|
@ -120,7 +120,7 @@ fn node_property<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
NodeProperty {
|
NodeProperty {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
name: Into::<&str>::into(name),
|
property_name: Into::<&str>::into(name),
|
||||||
value: None,
|
value: None,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
@ -133,7 +133,7 @@ fn node_property<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
NodeProperty {
|
NodeProperty {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
name: Into::<&str>::into(name),
|
property_name: Into::<&str>::into(name),
|
||||||
value: Some(value.into()),
|
value: Some(value.into()),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
@ -13,6 +13,7 @@ use nom::multi::many1;
|
|||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
|
use super::keyword::affiliated_keyword;
|
||||||
use super::keyword::table_formula_keyword;
|
use super::keyword::table_formula_keyword;
|
||||||
use super::object_parser::table_cell_set_object;
|
use super::object_parser::table_cell_set_object;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
@ -38,6 +39,8 @@ pub(crate) fn org_mode_table<'b, 'g, 'r, 's>(
|
|||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Table<'s>> {
|
) -> Res<OrgSource<'s>, Table<'s>> {
|
||||||
|
let (input, affiliated_keywords) =
|
||||||
|
many0(parser_with_context!(affiliated_keyword)(context))(input)?;
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
peek(tuple((space0, tag("|"))))(input)?;
|
peek(tuple((space0, tag("|"))))(input)?;
|
||||||
|
|
||||||
@ -68,6 +71,7 @@ pub(crate) fn org_mode_table<'b, 'g, 'r, 's>(
|
|||||||
remaining,
|
remaining,
|
||||||
Table {
|
Table {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
|
name: None, // TODO
|
||||||
formulas,
|
formulas,
|
||||||
children,
|
children,
|
||||||
},
|
},
|
||||||
|
@ -7,6 +7,7 @@ use super::StandardProperties;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PlainList<'s> {
|
pub struct PlainList<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
pub list_type: PlainListType,
|
pub list_type: PlainListType,
|
||||||
pub children: Vec<PlainListItem<'s>>,
|
pub children: Vec<PlainListItem<'s>>,
|
||||||
}
|
}
|
||||||
@ -46,19 +47,22 @@ pub enum CheckboxType {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CenterBlock<'s> {
|
pub struct CenterBlock<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
pub children: Vec<Element<'s>>,
|
pub children: Vec<Element<'s>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct QuoteBlock<'s> {
|
pub struct QuoteBlock<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
pub children: Vec<Element<'s>>,
|
pub children: Vec<Element<'s>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SpecialBlock<'s> {
|
pub struct SpecialBlock<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub name: &'s str,
|
pub name: Option<&'s str>,
|
||||||
|
pub block_type: &'s str,
|
||||||
pub parameters: Option<&'s str>,
|
pub parameters: Option<&'s str>,
|
||||||
pub children: Vec<Element<'s>>,
|
pub children: Vec<Element<'s>>,
|
||||||
}
|
}
|
||||||
@ -66,7 +70,8 @@ pub struct SpecialBlock<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DynamicBlock<'s> {
|
pub struct DynamicBlock<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub name: &'s str,
|
pub name: Option<&'s str>,
|
||||||
|
pub block_name: &'s str,
|
||||||
pub parameters: Option<&'s str>,
|
pub parameters: Option<&'s str>,
|
||||||
pub children: Vec<Element<'s>>,
|
pub children: Vec<Element<'s>>,
|
||||||
}
|
}
|
||||||
@ -74,6 +79,7 @@ pub struct DynamicBlock<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FootnoteDefinition<'s> {
|
pub struct FootnoteDefinition<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
pub label: &'s str,
|
pub label: &'s str,
|
||||||
pub children: Vec<Element<'s>>,
|
pub children: Vec<Element<'s>>,
|
||||||
}
|
}
|
||||||
@ -81,7 +87,8 @@ pub struct FootnoteDefinition<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Drawer<'s> {
|
pub struct Drawer<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub name: &'s str,
|
pub name: Option<&'s str>,
|
||||||
|
pub drawer_name: &'s str,
|
||||||
pub children: Vec<Element<'s>>,
|
pub children: Vec<Element<'s>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,13 +101,14 @@ pub struct PropertyDrawer<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NodeProperty<'s> {
|
pub struct NodeProperty<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub name: &'s str,
|
pub property_name: &'s str,
|
||||||
pub value: Option<&'s str>,
|
pub value: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Table<'s> {
|
pub struct Table<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
pub formulas: Vec<Keyword<'s>>,
|
pub formulas: Vec<Keyword<'s>>,
|
||||||
pub children: Vec<TableRow<'s>>,
|
pub children: Vec<TableRow<'s>>,
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ pub struct Clock<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DiarySexp<'s> {
|
pub struct DiarySexp<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -104,16 +105,19 @@ pub struct Planning<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FixedWidthArea<'s> {
|
pub struct FixedWidthArea<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct HorizontalRule<'s> {
|
pub struct HorizontalRule<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Keyword<'s> {
|
pub struct Keyword<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
pub key: &'s str,
|
pub key: &'s str,
|
||||||
pub value: &'s str,
|
pub value: &'s str,
|
||||||
}
|
}
|
||||||
@ -121,6 +125,7 @@ pub struct Keyword<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BabelCall<'s> {
|
pub struct BabelCall<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
pub key: &'s str,
|
pub key: &'s str,
|
||||||
pub value: &'s str,
|
pub value: &'s str,
|
||||||
}
|
}
|
||||||
@ -128,6 +133,7 @@ pub struct BabelCall<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct LatexEnvironment<'s> {
|
pub struct LatexEnvironment<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
|
pub name: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A line number used in switches to lesser blocks.
|
/// A line number used in switches to lesser blocks.
|
||||||
|
Loading…
Reference in New Issue
Block a user