From be91a614b07e1210153d350ee692ef57bf95b15b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 6 Feb 2023 19:21:12 +0200 Subject: feat: allow link() in pagespec to contain a glob Sponsored-by: author --- src/pagespec.lalrpop | 2 +- src/pagespec.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pagespec.lalrpop b/src/pagespec.lalrpop index bc07744..ccee2c4 100644 --- a/src/pagespec.lalrpop +++ b/src/pagespec.lalrpop @@ -9,7 +9,7 @@ pub Expr: Box = { Term: Box = { Glob => Box::new(Expr::Glob(<>)), - "link" "(" "." ")" => Box::new(Expr::LinksHereFunc), + "link" "(" ")" => Box::new(Expr::LinksHereFunc(<>)), "page" "(" ")" => Box::new(Expr::PageFunc(<>)), "!" => Box::new(Expr::Negate(t)), "(" ")" => e, diff --git a/src/pagespec.rs b/src/pagespec.rs index e3f617d..7af2acd 100644 --- a/src/pagespec.rs +++ b/src/pagespec.rs @@ -64,7 +64,7 @@ pub enum PageSpecError { #[derive(Debug)] pub enum Expr { Glob(String), - LinksHereFunc, + LinksHereFunc(String), PageFunc(String), Negate(Box), Op(Box, OpCode, Box), @@ -75,7 +75,7 @@ impl Expr { trace!("Expr::matches: path={:?} self={:?}", path, self); match self { Self::Glob(glob) => glob_matches(glob, path), - Self::LinksHereFunc => links_here(site, container, path), // FIXME: check its page + Self::LinksHereFunc(glob) => links_here(site, container, path, glob), Self::PageFunc(glob) => page_matches(site, container, glob, path), // FIXME: check its page Self::Negate(expr) => !expr.matches(site, container, path), Self::Op(left, op, right) => match op { @@ -148,7 +148,7 @@ fn glob_matches_helper(mut glob: &[char], mut path: &[char]) -> bool { glob.is_empty() && path.is_empty() } -fn links_here(site: &Site, container: &Path, path: &str) -> bool { +fn links_here(site: &Site, container: &Path, path: &str, _glob: &str) -> bool { trace!( "links_here: container={} path={:?}", container.display(), -- cgit v1.2.1