summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rwxr-xr-xgemtexter4
-rw-r--r--gemtexter-paul.buetow.org.conf2
-rw-r--r--lib/template.source.sh13
4 files changed, 21 insertions, 4 deletions
diff --git a/README.md b/README.md
index 1f54540..b8ecad1 100644
--- a/README.md
+++ b/README.md
@@ -187,6 +187,12 @@ See more entries about DTail and Golang:
Blablabla...
```
+Table of contents generation can be done in any template file. Just add:
+
+```
+<< template::inline::toc
+```
+
### Alternative configuration file path
If you don't want to mess with `gemtexter.conf`, you can use an alternative config file path in `~/.config/gemtexter.conf`, which takes precedence if it exists. Another way is to set the `CONFIG_FILE_PATH` environment variable, e.g.:
diff --git a/gemtexter b/gemtexter
index 47cbc0e..c722e15 100755
--- a/gemtexter
+++ b/gemtexter
@@ -5,8 +5,8 @@
declare -r ARG="$1"; shift
declare CONTENT_FILTER="$1"; shift
-declare -r VERSION=2.1.0
-declare -r VERSION_DESCR='release'
+declare -r VERSION=2.2.0
+declare -r VERSION_DESCR='develop'
declare -r GEMTEXTER="Gemtexter $VERSION-$VERSION_DESCR"
declare -r DATE_FORMAT='--iso-8601=seconds'
declare DATE=date
diff --git a/gemtexter-paul.buetow.org.conf b/gemtexter-paul.buetow.org.conf
index 1761106..942c0a4 100644
--- a/gemtexter-paul.buetow.org.conf
+++ b/gemtexter-paul.buetow.org.conf
@@ -3,7 +3,7 @@ declare -xr DOMAIN=paul.buetow.org
declare -xr SUBTITLE="Paul Buetow's contact information"
declare -xr AUTHOR='Paul Buetow'
declare -xr EMAIL='paul@nospam.buetow.org'
-declare -xr MASTODON_URI='https://fosstodon.org/@snonux'
+declare -x MASTODON_URI='https://fosstodon.org/@snonux'
declare -xr IMAGE_PATTERN='\.(jpg|png|gif)$'
declare -xr ATOM_MAX_ENTRIES=42
declare -xr CONTENT_BASE_DIR=../paul.buetow.org-content
diff --git a/lib/template.source.sh b/lib/template.source.sh
index 5a7f023..5d9e4c1 100644
--- a/lib/template.source.sh
+++ b/lib/template.source.sh
@@ -28,7 +28,10 @@ template::_generate_file () {
cd "$tpl_dir" || log PANIC "Unable to chdir to $tpl_dir"
log INFO "Generating $tpl_path -> $dest"
- export CURRENT_GMI="$dest" # Environt var can be used by .gmi.tpl
+ # Environment variables can be used from .gmi.tpl files
+ export CURRENT_TPL="$tpl_path"
+ export CURRENT_GMI="$dest"
+
template::_generate < "$tpl" > "$dest.tmp"
mv "$dest.tmp" "$dest"
log INFO "Done generating $dest"
@@ -87,6 +90,14 @@ template::inline::index () {
done | sort | uniq
}
+# To generate a table of contents
+template::inline::toc () {
+ echo '```'
+ echo 'Table of contents:'
+ $GREP '^#' "$(basename "$CURRENT_TPL")" | $SED 's/#/ /g; s/^ //;'
+ echo '```'
+}
+
template::test () {
assert::equals "$(template::_line '<< echo -n foo')" 'foo'
assert::equals "$(template::_line '<< echo foo')" 'foo'