diff options
| author | Andreu Botella | 2019-05-08 18:28:30 +0200 | 
|---|---|---|
| committer | Andreu Botella | 2019-05-08 18:28:30 +0200 | 
| commit | 543c97c71d9dd8b79507dc6fe352ad6bdcbe18b6 (patch) | |
| tree | d366cee189f40e3e76c31e79d51894ce81c98e97 /src | |
| parent | 7c69731a62bd71c5411395b8ee35bd5f68ec36fb (diff) | |
| download | rust-rst-543c97c71d9dd8b79507dc6fe352ad6bdcbe18b6.tar.bz2 | |
Adding an attribute type for the cols attribute of tgroup.
Diffstat (limited to 'src')
| -rw-r--r-- | src/document_tree/attribute_types.rs | 11 | ||||
| -rw-r--r-- | src/document_tree/extra_attributes.rs | 4 | 
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> }); | 
