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:
Tom Alexander
2023-10-04 20:01:09 -04:00
parent a26640355c
commit d8102b7bc2
32 changed files with 324 additions and 59 deletions

View File

@@ -7,6 +7,7 @@ use super::StandardProperties;
#[derive(Debug)]
pub struct PlainList<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub list_type: PlainListType,
pub children: Vec<PlainListItem<'s>>,
}
@@ -46,19 +47,22 @@ pub enum CheckboxType {
#[derive(Debug)]
pub struct CenterBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
pub struct QuoteBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
pub struct SpecialBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub name: Option<&'s str>,
pub block_type: &'s str,
pub parameters: Option<&'s str>,
pub children: Vec<Element<'s>>,
}
@@ -66,7 +70,8 @@ pub struct SpecialBlock<'s> {
#[derive(Debug)]
pub struct DynamicBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub name: Option<&'s str>,
pub block_name: &'s str,
pub parameters: Option<&'s str>,
pub children: Vec<Element<'s>>,
}
@@ -74,6 +79,7 @@ pub struct DynamicBlock<'s> {
#[derive(Debug)]
pub struct FootnoteDefinition<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub label: &'s str,
pub children: Vec<Element<'s>>,
}
@@ -81,7 +87,8 @@ pub struct FootnoteDefinition<'s> {
#[derive(Debug)]
pub struct Drawer<'s> {
pub source: &'s str,
pub name: &'s str,
pub name: Option<&'s str>,
pub drawer_name: &'s str,
pub children: Vec<Element<'s>>,
}
@@ -94,13 +101,14 @@ pub struct PropertyDrawer<'s> {
#[derive(Debug)]
pub struct NodeProperty<'s> {
pub source: &'s str,
pub name: &'s str,
pub property_name: &'s str,
pub value: Option<&'s str>,
}
#[derive(Debug)]
pub struct Table<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub formulas: Vec<Keyword<'s>>,
pub children: Vec<TableRow<'s>>,
}

View File

@@ -91,6 +91,7 @@ pub struct Clock<'s> {
#[derive(Debug)]
pub struct DiarySexp<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
}
#[derive(Debug)]
@@ -104,16 +105,19 @@ pub struct Planning<'s> {
#[derive(Debug)]
pub struct FixedWidthArea<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
}
#[derive(Debug)]
pub struct HorizontalRule<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
}
#[derive(Debug)]
pub struct Keyword<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub key: &'s str,
pub value: &'s str,
}
@@ -121,6 +125,7 @@ pub struct Keyword<'s> {
#[derive(Debug)]
pub struct BabelCall<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub key: &'s str,
pub value: &'s str,
}
@@ -128,6 +133,7 @@ pub struct BabelCall<'s> {
#[derive(Debug)]
pub struct LatexEnvironment<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
}
/// A line number used in switches to lesser blocks.