refactor: migrar reportes a Typst con plantilla compartida y scripts

- Reemplazar plantillas Markdown por template/report.typ y template/main.typ
- Agregar primer reporte: respuesta-observaciones-avance-1
- Agregar scripts build.sh, preview.sh y common.sh con salida en pdf/
- Actualizar README y AGENTS.md; simplificar .gitignore
This commit is contained in:
2026-10-28 09:53:53 -03:00
parent d5030bdc0d
commit 2009e91465
15 changed files with 310 additions and 112 deletions
+3
View File
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
source "$(dirname -- "${BASH_SOURCE[0]}")/common.sh"
build_pdf
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Shared setup; sourced by build.sh and preview.sh.
set -euo pipefail
repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
usage() {
echo "Usage: $0 [--force|-f] [document.typ | report-directory]"
echo "Defaults to reports/respuesta-observaciones-avance-1/main.typ. Relative paths use the current directory."
echo "Existing PDFs are preserved unless --force is given. Preview watches only with --force."
}
force=false
input=""
while [[ $# -gt 0 ]]; do
case "$1" in
--force|-f) force=true ;;
--help|-h) usage; exit 0 ;;
-*) echo "Error: unknown option: $1" >&2; usage >&2; exit 2 ;;
*)
if [[ -n "$input" ]]; then usage >&2; exit 2; fi
input="$1"
;;
esac
shift
done
input="${input:-$repo_root/reports/respuesta-observaciones-avance-1/main.typ}"
if [[ -d "$input" ]]; then input="$input/main.typ"; fi
if [[ ! -f "$input" || "$input" != *.typ ]]; then
echo "Error: expected an existing .typ file: $input" >&2
exit 1
fi
input="$(realpath -- "$input")"
case "$input" in
"$repo_root/template/"*)
echo "Error: las plantillas no generan PDF; copie el documento base a reports/ primero." >&2
exit 1
;;
esac
name="$(basename -- "$input" .typ)"
if [[ "$name" == main ]]; then
name="$(basename -- "$(cd -- "$(dirname -- "$input")" && pwd)")"
fi
output="$repo_root/pdf/$name.pdf"
require_typst() {
command -v typst >/dev/null 2>&1 || {
echo "Error: install Typst and make it available on PATH." >&2
exit 1
}
}
build_pdf() {
if [[ -e "$output" && "$force" == false ]]; then
printf 'PDF existente: %s (use --force para regenerar)\n' "$output"
return
fi
require_typst
mkdir -p -- "$repo_root/pdf"
typst compile --root "$repo_root" "$input" "$output"
printf 'PDF: %s\n' "$output"
}
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
source "$(dirname -- "${BASH_SOURCE[0]}")/common.sh"
if [[ "$force" == true ]]; then
require_typst
mkdir -p -- "$repo_root/pdf"
exec typst watch --root "$repo_root" "$input" "$output" --open
fi
build_pdf
# Use an absolute path so the viewer also handles names starting with a dash.
pdf_path="$(cd -- "$(dirname -- "$output")" && pwd)/$(basename -- "$output")"
if command -v xdg-open >/dev/null 2>&1; then
exec xdg-open "$pdf_path"
elif command -v open >/dev/null 2>&1; then
exec open "$pdf_path"
else
echo "Error: no PDF opener found (xdg-open or open). PDF: $pdf_path" >&2
exit 1
fi