summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpackaging/package_debian.sh3
-rw-r--r--skaldpress.150
-rw-r--r--smp.12
-rw-r--r--src/macro_processor/macro_processor.rs12
-rw-r--r--src/skaldpress/parseopts.rs2
5 files changed, 66 insertions, 3 deletions
diff --git a/packaging/package_debian.sh b/packaging/package_debian.sh
index 73ad0cc..920574f 100755
--- a/packaging/package_debian.sh
+++ b/packaging/package_debian.sh
@@ -18,7 +18,8 @@ mkdir -p ${mandir}
cp -r packaging/DEBIAN ${dir}/DEBIAN
cp target/release/skaldpress ${bindir}/skaldpress
-#cp skaldpress.1 ${mandir}/skaldpress.1
+cp skaldpress.1 ${mandir}/skaldpress.1
+cp smp.1 ${mandir}/smp.1
cd ${tmpdir}
dpkg-deb --build skaldpress
diff --git a/skaldpress.1 b/skaldpress.1
new file mode 100644
index 0000000..c6928e7
--- /dev/null
+++ b/skaldpress.1
@@ -0,0 +1,50 @@
+.TH SKALDPRESS 1 2024-06-08
+.SH name
+Skaldpress \- Templating engine
+.SH SYNOPSIS
+.B skaldpress [OPTIONS]
+
+.SH DESCRIPTION
+.B smp
+smp is a macro processor, made specifically for a usecase when doing templating of websites.
+
+
+Macros which are available using skaldpress, in addition to the builtin smp(1)-macros
+.IP "\fBtemplate(<template>,<content>)\fR"
+Will process the content using a template, in-place.
+This macro is used by the \fBall_tagged_by\fR-macro.
+
+.IP "\fBall_tagged_by(<tag_name>,<template>[,<field to sort by>][,<reversed>])\fR"
+Will output all documents which had the specified tag, using the specified template.
+If a field to sort by is specified, it will output ascending based on that field,
+or reversed if a fourth argument \fBreversed\fR is specified.
+
+.SH OPTIONS
+.IP "\fB-o, --out\fR \fIpath\fR
+Specifies the directory to output the compiled files to, defaults to \fIbuild\fR.
+
+.IP "\fB-s, --source\fR \fIpath\fR
+Specifies the directory where all files are iterated, defaults to \fIcontent\fR.
+
+.IP "\fB-t, --templates\fR \fIpath\fR
+Specifies the directory where templates are stored, defaults to \fItemplates\fR.
+
+.IP "\fB-f, --filter\fR \fIfilter\fR
+Comma-separated list of files to compile, if not specified, all files in \fB--source\fR
+will be compiled.
+
+.SH EXAMPLES
+
+To run skaldpress on a simple project, simply call it with no arguments
+in a directory where you have a \fBcontent\fR-directory,
+and optionally a \fBtemplates\fR-directory.
+.PP
+.nf
+.RS
+skaldpress
+.RE
+.fi
+.PP
+
+.SH SEE ALSO
+smp(1)
diff --git a/smp.1 b/smp.1
index 3cdab73..78d2973 100644
--- a/smp.1
+++ b/smp.1
@@ -1,6 +1,6 @@
.TH SMP 1 2024-06-08
.SH name
-Skaldpress Macro Processor \- Text graphing utility
+Skaldpress Macro Processor \- Macro processor
.SH SYNOPSIS
.B smp [\fIinput_file\fB]
diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs
index 85bf8e1..96d5471 100644
--- a/src/macro_processor/macro_processor.rs
+++ b/src/macro_processor/macro_processor.rs
@@ -246,6 +246,7 @@ pub enum MacroType {
),
/// Will be expanded in-place to the String
String(String),
+ Array(Vec<MacroType>),
}
/// Possible parser states
@@ -339,6 +340,17 @@ impl MacroProcessor {
self.macros.insert(name, macro_expansion);
}
+ pub fn array_push(&mut self, name: String, element: MacroType) -> Result<(), SMPError> {
+ let Some(macro_body) = self.macros.get_mut(&name) else {
+ return Err(SMPError::UnknownError(4, None));
+ };
+ let MacroType::Array(array) = macro_body else {
+ return Err(SMPError::UnknownError(5, None));
+ };
+ array.push(element);
+ Ok(())
+ }
+
/// This expands a macro definition, and it executes builtin functions, like define
///
/// # Arguments
diff --git a/src/skaldpress/parseopts.rs b/src/skaldpress/parseopts.rs
index 36fbf13..3985684 100644
--- a/src/skaldpress/parseopts.rs
+++ b/src/skaldpress/parseopts.rs
@@ -135,7 +135,7 @@ pub fn parseopts() -> OptsBuilder {
} else {
arg_name = arg.clone();
match arg_name.as_str() {
- "out" | "source" | "templates" => {
+ "out" | "source" | "templates" | "filter" => {
arg_value = it.next();
}
_ => (),