aboutsummaryrefslogtreecommitdiffstats
path: root/src/document_tree
diff options
context:
space:
mode:
Diffstat (limited to 'src/document_tree')
-rw-r--r--src/document_tree/attribute_types.rs11
-rw-r--r--src/document_tree/extra_attributes.rs4
2 files changed, 13 insertions, 2 deletions
diff --git a/src/document_tree/attribute_types.rs b/src/document_tree/attribute_types.rs
index 4a9bd3d..e98118a 100644
--- a/src/document_tree/attribute_types.rs
+++ b/src/document_tree/attribute_types.rs
@@ -29,6 +29,16 @@ impl Default for FixedSpace { fn default() -> FixedSpace { FixedSpace::Preserve
#[derive(Debug,PartialEq,Eq,Hash,Serialize)] pub struct ID(pub String);
#[derive(Debug,PartialEq,Eq,Hash,Serialize)] pub struct NameToken(pub String);
+// The table DTD has the cols attribute of tgroup as required, but having
+// TableGroupCols not implement Default would leave no possible implementation
+// for TableGroup::with_children.
+#[derive(Debug,PartialEq,Eq,Hash,Serialize)] pub struct TableGroupCols(pub usize);
+impl Default for TableGroupCols {
+ fn default() -> Self {
+ TableGroupCols(0)
+ }
+}
+
// no eq for f64
#[derive(Debug,PartialEq,Serialize)]
pub enum Measure { // http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#length-units
@@ -125,6 +135,7 @@ macro_rules! impl_cannot_be_empty {
};
}
impl_cannot_be_empty!(target::Target);
+impl_cannot_be_empty!(TableGroupCols);
impl<T> CanBeEmpty for Option<T> {
fn is_empty(&self) -> bool { self.is_none() }
diff --git a/src/document_tree/extra_attributes.rs b/src/document_tree/extra_attributes.rs
index 35f4b5a..bff9fb3 100644
--- a/src/document_tree/extra_attributes.rs
+++ b/src/document_tree/extra_attributes.rs
@@ -1,7 +1,7 @@
use serde_derive::Serialize;
use crate::target;
-use super::attribute_types::{CanBeEmpty,FixedSpace,ID,NameToken,AlignHV,AlignH,AlignV,TableAlignH,TableBorder,Measure,EnumeratedListType};
+use super::attribute_types::{CanBeEmpty,FixedSpace,ID,NameToken,AlignHV,AlignH,AlignV,TableAlignH,TableBorder,TableGroupCols,Measure,EnumeratedListType};
pub trait ExtraAttributes<A> {
fn with_extra(extra: A) -> Self;
@@ -63,7 +63,7 @@ impl_extra!(SystemMessage { backrefs: Vec<ID>, level: Option<usize>, line: Optio
impl_extra!(Figure { align: Option<AlignH>, width: Option<usize> });
impl_extra!(Table { frame: Option<TableBorder>, colsep: Option<bool>, rowsep: Option<bool>, pgwide: Option<bool> });
-impl_extra!(TableGroup { cols: usize, colsep: Option<bool>, rowsep: Option<bool>, align: Option<TableAlignH> });
+impl_extra!(TableGroup { cols: TableGroupCols, colsep: Option<bool>, rowsep: Option<bool>, align: Option<TableAlignH> });
impl_extra!(TableHead { valign: Option<AlignV> });
impl_extra!(TableBody { valign: Option<AlignV> });
impl_extra!(TableRow { rowsep: Option<bool>, valign: Option<AlignV> });