diff --git a/scripts/build-frontmatter.sh b/scripts/build-frontmatter.sh deleted file mode 100755 index aa2c4c0..0000000 --- a/scripts/build-frontmatter.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -# Usage: scripts/build-frontmatter.sh conf/metadata.yaml templates/frontmatter.html conf/frontmatter.html -# Description: -# Reads templates/frontmatter.html or templates/frontmatter.tex -# Replaces all $key$ with values from metadata.yaml -# Writes result to conf/frontmatter.html or frontmatter.tex -# Requirements: -# metadata.yaml must be flat (key: value) - -set -euo pipefail - -META_FILE="$1" -TEMPLATE_FILE="$2" -OUTPUT_FILE="$3" -TEMP_FILE="scripts/tmp/frontmatter.tmp" - -# Check arguments -echo " META_FILE: $META_FILE" -echo " TEMPLATE_FILE: $TEMPLATE_FILE" -echo " OUTPUT_FILE: $OUTPUT_FILE" -echo " TEMP_FILE: $TEMP_FILE" -echo "" - -# Start fresh output -cp "$TEMPLATE_FILE" "$OUTPUT_FILE" - -# Load metadata into Bash associative array -declare -A META -while IFS= read -r line; do - # skip empty or comment lines - [[ -z "$line" || "$line" =~ ^# ]] && continue - - key=$(echo "$line" | cut -d ':' -f 1 | xargs) - val=$(echo "$line" | cut -d ':' -f 2- | xargs) # capture full value after first colon, trim spaces - - # strip surrounding quotes if present - val="${val%\"}" - val="${val#\"}" - - META["$key"]="$val" -done < "$META_FILE" - -# Read template line by line and substitute -for key in "${!META[@]}"; do - # Strip leading/trailing whitespace and quotes - val="${META[$key]}" - val="${val%\"}" # remove trailing " - val="${val#\"}" # remove leading " - val="$(echo "$val" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" # trim spaces safely - - # Escape special chars for sed - esc_val=$(printf '%s' "$val" | sed -e 's/[\/&$]/\\&/g') - - search_key="\$${key}\$" - echo " Replacing ${search_key} → ${val}" - sed -i "s|\\\$${key}\\\$|${val}|g" "$OUTPUT_FILE" - # ls -l "$OUTPUT_FILE" -done - -echo "✅ Rendered: $OUTPUT_FILE" diff --git a/scripts/install-build-deps.sh b/scripts/install-build-deps.sh deleted file mode 100755 index c56ebf7..0000000 --- a/scripts/install-build-deps.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -set -e - -REQ_PKGS=( - make - pandoc - texlive - texlive-xetex - texlive-latex-extra - texlive-fonts-recommended - texlive-fonts-extra - lmodern - epubcheck -) - -echo "==> Checking and installing build dependencies" - -install_pkg() { - PKG="$1" - if dpkg -s "$PKG" >/dev/null 2>&1; then - echo " ✅ $PKG already installed" - else - echo " ➕ Installing $PKG" - sudo apt-get install -y "$PKG" - fi -} - -echo "==> Updating package index" -sudo apt-get update -y - -for PKG in "${REQ_PKGS[@]}"; do - install_pkg "$PKG" -done - -echo "" -echo "==> Verifying MathJax directory..." -if [ -d "lib/mathjax" ]; then - echo " ✅ MathJax directory exists" -else - echo " ❌ MathJax directory missing!" - echo " Please restore lib/mathjax/ or re-clone repo" - exit 1 -fi - -echo "" -echo "🎉 Build environment ready." -echo "Try building with:" -echo " make pdf" -echo " make html" -echo " make epub" -echo "" diff --git a/scripts/new-project.sh b/scripts/new-project.sh old mode 100644 new mode 100755 index d68b7e1..8d1cbd6 --- a/scripts/new-project.sh +++ b/scripts/new-project.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# Usage: scripts/new-project.sh set -euo pipefail # Check arguments @@ -8,16 +7,15 @@ if [ "$#" -ne 1 ]; then exit 1 fi -# Gets Script Directory -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -B3_DIR=$( cd -- "$( dirname -- "$SCRIPT_DIR/.." )" &> /dev/null && pwd ) +# Resolve directories +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +B3_DIR="$( cd -- "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd )" -# Create project directory PROJECT_DIR="$1" mkdir -p "$PROJECT_DIR" -echo "$SCRIPT_DIR" -echo "$B3_DIR" +echo "Script dir: $SCRIPT_DIR" +echo "Template root: $B3_DIR" -# Copy B3 template to project directory -#rsync -av --exclude ".git" "$B3_DIR/" "$PROJECT_DIR" +# Copy template (excluding .git) +# rsync -av --exclude ".git" "$B3_DIR/" "$PROJECT_DIR"