aboutsummaryrefslogtreecommitdiffstats
path: root/src/document_tree/element_categories.rs
diff options
context:
space:
mode:
authorPhil Schaf2015-11-14 20:13:45 +0100
committerPhil Schaf2015-11-14 20:13:45 +0100
commit5fdb21df228c78061cce9ee910fa87da0fd99d46 (patch)
tree707d234259202381be0c784e8f1efea8eb5081ec /src/document_tree/element_categories.rs
parent9c2f818b7e7139ed7a5da573d1cc104defa7579f (diff)
downloadrust-rst-5fdb21df228c78061cce9ee910fa87da0fd99d46.tar.bz2
redesign
Diffstat (limited to 'src/document_tree/element_categories.rs')
-rw-r--r--src/document_tree/element_categories.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/document_tree/element_categories.rs b/src/document_tree/element_categories.rs
new file mode 100644
index 0000000..5f12cc6
--- /dev/null
+++ b/src/document_tree/element_categories.rs
@@ -0,0 +1,59 @@
+use super::elements::*;
+
+pub trait HasChildren<C> {
+ fn add_child<R: Into<C>>(&mut self, R);
+}
+
+macro_rules! synonymous_enum {( $name:ident { $( $entry:ident ),* } ) => (
+ #[derive(Debug)]
+ pub enum $name {
+ $(
+ $entry($entry),
+ )*
+ }
+
+ $(
+ impl Into<$name> for $entry {
+ fn into(self) -> $name {
+ $name::$entry(self)
+ }
+ }
+ )*
+)}
+
+synonymous_enum!(SubStructure { Topic, Sidebar, Transition, Section, BodyElement });
+synonymous_enum!(StructuralSubElement { Title, Subtitle, Decoration, Docinfo, Transition, SubStructure });
+synonymous_enum!(BodyElement {
+ //Simple
+ Paragraph, LiteralBlock, DoctestBlock, MathBlock, Rubric, SubstitutionDefinition, Comment, Pending, Target, Raw, Image,
+ //Compound
+ Compound, Container,
+ BulletList, EnumeratedList, DefinitionList, FieldList, OptionList,
+ LineBlock, BlockQuote, Admonition, Attention, Hint, Note, Caution, Danger, Error, Important, Tip, Warning, Footnote, Citation, SystemMessage, Figure, Table
+});
+
+synonymous_enum!(BibliographicElement { Author, Authors, Organization, Address, Contact, Version, Revision, Status, Date, Copyright, Field });
+
+synonymous_enum!(TextOrInlineElement {
+ TextElement, Emphasis, Strong, Literal, Reference, FootnoteReference, CitationReference, SubstitutionReference, TitleReference, Abbreviation, Acronym, Superscript, Subscript, Inline, Problematic, Generated, Math,
+ //also have non-inline versions. Inline image is no figure child, inline target has content
+ TargetInline, RawInline, ImageInline
+});
+
+//--------------\\
+//Content Models\\
+//--------------\\
+
+synonymous_enum!(SubSection { Title, Subtitle, Docinfo, Decoration, SubStructure, BodyElement });
+synonymous_enum!(AuthorInfo { Author, Organization, Address, Contact });
+synonymous_enum!(DecorationElement { Header, Footer });
+synonymous_enum!(SubTopic { Title, BodyElement });
+synonymous_enum!(SubSidebar { Topic, Title, Subtitle, BodyElement });
+synonymous_enum!(SubDLItem { Term, Classifier, Definition });
+synonymous_enum!(SubField { FieldName, FieldBody });
+synonymous_enum!(SubOptionListItem { OptionGroup, Description });
+synonymous_enum!(SubOption { OptionString, OptionArgument });
+synonymous_enum!(SubLineBlock { LineBlock, Line });
+synonymous_enum!(SubBlockQuote { Attribution, BodyElement });
+synonymous_enum!(SubFootnote { Label_, BodyElement });
+synonymous_enum!(SubFigure { Image, Caption, Legend, BodyElement });