summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-07-24 09:22:04 +0300
committerLars Wirzenius <liw@liw.fi>2022-07-24 09:22:04 +0300
commitc619847d4213504ff2fb28a814d32ea642c24287 (patch)
tree908f685bd7bc761c8424a079698c09d532f342dc
parent6869df7dedd8b434cb676fb25e9631b7723f0f28 (diff)
downloadriki-c619847d4213504ff2fb28a814d32ea642c24287.tar.gz
feat: add placeholder for tag directive
Sponsored-by: author
-rw-r--r--src/directive/mod.rs9
-rw-r--r--src/directive/tag.rs32
2 files changed, 41 insertions, 0 deletions
diff --git a/src/directive/mod.rs b/src/directive/mod.rs
index efdc799..38fb0d3 100644
--- a/src/directive/mod.rs
+++ b/src/directive/mod.rs
@@ -14,6 +14,7 @@ pub enum Directive {
Meta(Meta),
Img(Img),
+ Tag(Tag),
}
impl TryFrom<ParsedDirective> for Directive {
@@ -49,6 +50,10 @@ impl TryFrom<ParsedDirective> for Directive {
Self::check_args(&p, Meta::REQUIRED, Meta::ALLOWED, Meta::ALLOW_ANY_UNNAMED)?;
Directive::Meta(Meta::from(p))
}
+ "tag" => {
+ Self::check_args(&p, Tag::REQUIRED, Tag::ALLOWED, Tag::ALLOW_ANY_UNNAMED)?;
+ Directive::Tag(Tag::from(p))
+ }
_ => return Err(SiteError::UnknownDirective(p.name().into())),
};
Ok(d)
@@ -97,6 +102,7 @@ impl Directive {
}
Self::Img(x) => x.process(site, meta),
Self::Meta(x) => x.process(site, meta),
+ Self::Tag(x) => x.process(site, meta),
}
}
}
@@ -106,3 +112,6 @@ use meta::Meta;
mod img;
pub use img::Img;
+
+mod tag;
+use tag::Tag;
diff --git a/src/directive/tag.rs b/src/directive/tag.rs
new file mode 100644
index 0000000..9486a7b
--- /dev/null
+++ b/src/directive/tag.rs
@@ -0,0 +1,32 @@
+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)
+ }
+}