Update all elements to the new AffiliatedKeywords.

This commit is contained in:
Tom Alexander
2023-10-11 14:44:25 -04:00
parent aa33fe42a8
commit 9523365090
19 changed files with 162 additions and 97 deletions

View File

@@ -23,3 +23,11 @@ pub struct AffiliatedKeywords<'s> {
pub trait GetAffiliatedKeywords<'s> {
fn get_affiliated_keywords<'a>(&'a self) -> &'a AffiliatedKeywords<'s>;
}
impl<'s> Default for AffiliatedKeywords<'s> {
fn default() -> Self {
AffiliatedKeywords {
keywords: BTreeMap::new(),
}
}
}

View File

@@ -10,7 +10,6 @@ use super::StandardProperties;
pub struct PlainList<'s> {
pub source: &'s str,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub name: Option<&'s str>,
pub list_type: PlainListType,
pub children: Vec<PlainListItem<'s>>,
}
@@ -50,21 +49,21 @@ pub enum CheckboxType {
#[derive(Debug)]
pub struct CenterBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
pub struct QuoteBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
pub struct SpecialBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub block_type: &'s str,
pub parameters: Option<&'s str>,
pub children: Vec<Element<'s>>,
@@ -73,7 +72,7 @@ pub struct SpecialBlock<'s> {
#[derive(Debug)]
pub struct DynamicBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub block_name: &'s str,
pub parameters: Option<&'s str>,
pub children: Vec<Element<'s>>,
@@ -82,7 +81,7 @@ pub struct DynamicBlock<'s> {
#[derive(Debug)]
pub struct FootnoteDefinition<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub label: &'s str,
pub children: Vec<Element<'s>>,
}
@@ -90,7 +89,7 @@ pub struct FootnoteDefinition<'s> {
#[derive(Debug)]
pub struct Drawer<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub drawer_name: &'s str,
pub children: Vec<Element<'s>>,
}
@@ -111,7 +110,7 @@ pub struct NodeProperty<'s> {
#[derive(Debug)]
pub struct Table<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub formulas: Vec<Keyword<'s>>,
pub children: Vec<TableRow<'s>>,
}

View File

@@ -1,4 +1,5 @@
use super::object::Object;
use super::AffiliatedKeywords;
use super::PlainText;
use super::StandardProperties;
use super::Timestamp;
@@ -6,7 +7,7 @@ use super::Timestamp;
#[derive(Debug)]
pub struct Paragraph<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub children: Vec<Object<'s>>,
}
@@ -25,7 +26,7 @@ pub struct TableCell<'s> {
#[derive(Debug)]
pub struct VerseBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub data: Option<&'s str>,
pub children: Vec<Object<'s>>,
}
@@ -33,7 +34,7 @@ pub struct VerseBlock<'s> {
#[derive(Debug)]
pub struct CommentBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub contents: &'s str,
}
@@ -50,7 +51,7 @@ pub enum RetainLabels {
#[derive(Debug)]
pub struct ExampleBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub switches: Option<&'s str>,
pub number_lines: Option<SwitchNumberLines>,
pub preserve_indent: Option<CharOffsetInLine>,
@@ -63,7 +64,7 @@ pub struct ExampleBlock<'s> {
#[derive(Debug)]
pub struct ExportBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub export_type: Option<&'s str>,
pub data: Option<&'s str>,
pub contents: String,
@@ -72,7 +73,7 @@ pub struct ExportBlock<'s> {
#[derive(Debug)]
pub struct SrcBlock<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub language: Option<&'s str>,
pub switches: Option<&'s str>,
pub parameters: Option<&'s str>,
@@ -101,7 +102,7 @@ pub struct Clock<'s> {
#[derive(Debug)]
pub struct DiarySexp<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub value: &'s str,
}
@@ -116,20 +117,20 @@ pub struct Planning<'s> {
#[derive(Debug)]
pub struct FixedWidthArea<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub value: Vec<&'s str>,
}
#[derive(Debug)]
pub struct HorizontalRule<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
}
#[derive(Debug)]
pub struct Keyword<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub key: &'s str,
pub value: &'s str,
}
@@ -137,7 +138,7 @@ pub struct Keyword<'s> {
#[derive(Debug)]
pub struct BabelCall<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub value: &'s str,
pub call: Option<&'s str>,
pub inside_header: Option<&'s str>,
@@ -148,7 +149,7 @@ pub struct BabelCall<'s> {
#[derive(Debug)]
pub struct LatexEnvironment<'s> {
pub source: &'s str,
pub name: Option<&'s str>,
pub affiliated_keywords: AffiliatedKeywords<'s>,
pub value: &'s str,
}
@@ -172,7 +173,7 @@ impl<'s> Paragraph<'s> {
objects.push(Object::PlainText(PlainText { source: input }));
Paragraph {
source: input,
name: None,
affiliated_keywords: AffiliatedKeywords::default(),
children: objects,
}
}