summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-08-05 22:28:58 +0300
committerLars Wirzenius <liw@liw.fi>2022-08-06 07:25:14 +0300
commitea1a5a1e9c837816a0c89793e13f032f2cba50e1 (patch)
treec75c1cf5e8f419ce13e160d246685a48ffba6dbd
parenta39707b18a498fa3519c3772ef5f80cdbd8d3af6 (diff)
downloadriki-ea1a5a1e9c837816a0c89793e13f032f2cba50e1.tar.gz
feat: add placeholder for the inline directive
Sponsored-by: author
-rw-r--r--src/directive/inline.rs38
-rw-r--r--src/directive/mod.rs9
2 files changed, 47 insertions, 0 deletions
diff --git a/src/directive/inline.rs b/src/directive/inline.rs
new file mode 100644
index 0000000..efaf7ee
--- /dev/null
+++ b/src/directive/inline.rs
@@ -0,0 +1,38 @@
+use crate::error::SiteError;
+use crate::page::PageMeta;
+use crate::site::Site;
+use crate::wikitext::ParsedDirective;
+
+#[derive(Debug, Default, Eq, PartialEq)]
+pub struct Inline {}
+
+impl Inline {
+ pub const REQUIRED: &'static [&'static str] = &["pages"];
+ pub const ALLOWED: &'static [&'static str] = &[
+ "actions",
+ "archive",
+ "description",
+ "feedlimit",
+ "feeds",
+ "feedshow",
+ "limit",
+ "sort",
+ "template",
+ "trail",
+ ];
+ pub const ALLOW_ANY_UNNAMED: bool = true;
+
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ pub fn process(&self, _site: &Site, _meta: &mut PageMeta) -> Result<String, SiteError> {
+ Ok("FIXME:inline".into())
+ }
+}
+
+impl From<ParsedDirective> for Inline {
+ fn from(_p: ParsedDirective) -> Self {
+ Inline::new()
+ }
+}
diff --git a/src/directive/mod.rs b/src/directive/mod.rs
index 38fb0d3..a97f3a5 100644
--- a/src/directive/mod.rs
+++ b/src/directive/mod.rs
@@ -14,6 +14,7 @@ pub enum Directive {
Meta(Meta),
Img(Img),
+ Inline(Inline),
Tag(Tag),
}
@@ -46,6 +47,10 @@ impl TryFrom<ParsedDirective> for Directive {
Self::check_args(&p, Img::REQUIRED, Img::ALLOWED, Img::ALLOW_ANY_UNNAMED)?;
Directive::Img(Img::from(p))
}
+ "inline" => {
+ Self::check_args(&p, Inline::REQUIRED, Inline::ALLOWED, Inline::ALLOW_ANY_UNNAMED)?;
+ Directive::Inline(Inline::from(p))
+ }
"meta" => {
Self::check_args(&p, Meta::REQUIRED, Meta::ALLOWED, Meta::ALLOW_ANY_UNNAMED)?;
Directive::Meta(Meta::from(p))
@@ -101,6 +106,7 @@ impl Directive {
panic!("directive {:?} may only be used in parsing tests", self)
}
Self::Img(x) => x.process(site, meta),
+ Self::Inline(x) => x.process(site, meta),
Self::Meta(x) => x.process(site, meta),
Self::Tag(x) => x.process(site, meta),
}
@@ -113,5 +119,8 @@ use meta::Meta;
mod img;
pub use img::Img;
+mod inline;
+pub use inline::Inline;
+
mod tag;
use tag::Tag;