summaryrefslogtreecommitdiff
path: root/src/directive/table.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/directive/table.rs')
-rw-r--r--src/directive/table.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/directive/table.rs b/src/directive/table.rs
index 7610a6b..2bbfbc8 100644
--- a/src/directive/table.rs
+++ b/src/directive/table.rs
@@ -1,3 +1,4 @@
+use crate::directive::{DirectiveImplementation, Processed};
use crate::error::SiteError;
use crate::page::PageMeta;
use crate::site::Site;
@@ -9,16 +10,16 @@ pub struct Table {
data: String,
}
-impl Table {
- pub const REQUIRED: &'static [&'static str] = &["data"];
- pub const ALLOWED: &'static [&'static str] = &[];
- pub const ALLOW_ANY_UNNAMED: bool = true;
+impl DirectiveImplementation for Table {
+ const REQUIRED: &'static [&'static str] = &["data"];
+ const ALLOWED: &'static [&'static str] = &[];
+ const ALLOW_ANY_UNNAMED: bool = true;
- pub fn new(data: String) -> Self {
- Self { data }
+ fn from_parsed(p: &ParsedDirective) -> Self {
+ Self::new(p.args().get("data").unwrap().to_string())
}
- pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result<String, SiteError> {
+ fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result<Processed, SiteError> {
let mut table = String::new();
let mut lines = self.data.trim().lines();
if let Some(first) = lines.next() {
@@ -36,12 +37,12 @@ impl Table {
}
debug!("table data: {}", self.data);
debug!("table: {}", table);
- Ok(table)
+ Ok(Processed::Markdown(table))
}
}
-impl From<&ParsedDirective> for Table {
- fn from(p: &ParsedDirective) -> Self {
- Table::new(p.args().get("data").unwrap().to_string())
+impl Table {
+ pub fn new(data: String) -> Self {
+ Self { data }
}
}