diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-08-05 22:44:40 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-08-06 07:25:14 +0300 |
commit | 4d20badb243c2ae57b8b54d0c5e025b43957dd8f (patch) | |
tree | ce76662098c31dd2a60f816f2dca531f0590872c | |
parent | 51f773726a9b6640e21c0601e61700603c18d462 (diff) | |
download | riki-4d20badb243c2ae57b8b54d0c5e025b43957dd8f.tar.gz |
feat: placeholder for toc directive
Sponsored-by: author
-rw-r--r-- | src/directive/mod.rs | 9 | ||||
-rw-r--r-- | src/directive/toc.rs | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/directive/mod.rs b/src/directive/mod.rs index 59c352c..0767c9d 100644 --- a/src/directive/mod.rs +++ b/src/directive/mod.rs @@ -17,6 +17,7 @@ pub enum Directive { Inline(Inline), PageStats(PageStats), Tag(Tag), + Toc(Toc), } impl TryFrom<ParsedDirective> for Directive { @@ -64,6 +65,10 @@ impl TryFrom<ParsedDirective> for Directive { Self::check_args(&p, Tag::REQUIRED, Tag::ALLOWED, Tag::ALLOW_ANY_UNNAMED)?; Directive::Tag(Tag::from(p)) } + "toc" => { + Self::check_args(&p, Toc::REQUIRED, Toc::ALLOWED, Toc::ALLOW_ANY_UNNAMED)?; + Directive::Toc(Toc::from(p)) + } _ => return Err(SiteError::UnknownDirective(p.name().into())), }; Ok(d) @@ -115,6 +120,7 @@ impl Directive { Self::Meta(x) => x.process(site, meta), Self::PageStats(x) => x.process(site, meta), Self::Tag(x) => x.process(site, meta), + Self::Toc(x) => x.process(site, meta), } } } @@ -133,3 +139,6 @@ pub use pagestats::PageStats; mod tag; use tag::Tag; + +mod toc; +use toc::Toc; diff --git a/src/directive/toc.rs b/src/directive/toc.rs new file mode 100644 index 0000000..6db46d2 --- /dev/null +++ b/src/directive/toc.rs @@ -0,0 +1,27 @@ +use crate::error::SiteError; +use crate::page::PageMeta; +use crate::site::Site; +use crate::wikitext::ParsedDirective; + +#[derive(Debug, Default, Eq, PartialEq)] +pub struct Toc {} + +impl Toc { + pub const REQUIRED: &'static [&'static str] = &[]; + pub const ALLOWED: &'static [&'static str] = &["levels"]; + 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 Toc { + fn from(_p: ParsedDirective) -> Self { + Self::new() + } +} |