summaryrefslogtreecommitdiff
path: root/src/directive/tag.rs
blob: baf45619181b367c7b3233ca25d39dde24c464c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::error::SiteError;
use crate::page::PageMeta;
use crate::site::Site;
use crate::wikitext::ParsedDirective;

#[derive(Debug, Eq, PartialEq)]
pub struct Tag {
    tags: Vec<String>,
}

impl Tag {
    pub const REQUIRED: &'static [&'static str] = &[];
    pub const ALLOWED: &'static [&'static str] = &["class"];
    pub const ALLOW_ANY_UNNAMED: bool = true;

    pub fn new(tags: Vec<String>) -> Self {
        Self { tags }
    }

    pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result<String, SiteError> {
        Ok("".into())
    }
}

impl From<ParsedDirective> for Tag {
    fn from(p: ParsedDirective) -> Self {
        let tags = p.unnamed_args().iter().map(|s| s.to_string()).collect();
        Tag::new(tags)
    }
}