aboutsummaryrefslogtreecommitdiff
path: root/justfile
blob: 19b52f26792129cc877333e56c6ddcef9f00a274 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Justfile for Marp presentations

# Default command
default:
    just help

# Show help
help:
    @echo "Commands:"
    @echo "  build <file>    - Build HTML"
    @echo "  watch <file>    - Watch and rebuild"
    @echo "  pdf <file>      - Export to PDF"
    @echo "  new <name>      - Create presentation"
    @echo "  clean           - Remove output files"
    @echo "  cleanup         - Clean everything including node_modules"
    @echo "  demo            - Build demo presentations"
    @echo ""
    @echo "Themes: acarp (16:9), acarp-beamer (4:3)"
    @echo "Layouts: title, layout-2col"

# Install dependencies
install:
    npm install

# Check if dependencies are installed, install if needed
deps:
    @if [ ! -d "node_modules" ] || [ ! -f "package-lock.json" ]; then \
        echo "Installing dependencies..."; \
        npm install; \
    fi

# Build HTML from markdown
build file: deps
    npx marp --config .marprc.json --html {{file}}

# Watch markdown file and rebuild on changes
watch file: deps
    npx marp --config .marprc.json --watch {{file}}

# Convert to PDF
pdf file: deps
    npx marp --config .marprc.json --pdf --browser chrome {{file}}

# Build and open HTML file
build-open file: (build file)
    #!/usr/bin/env sh
    html_file="$(echo "{{file}}" | sed 's/\.md$/.html/')"
    echo "Opening $html_file..."
    if command -v xdg-open > /dev/null; then
        xdg-open "$html_file"
    elif command -v open > /dev/null; then
        open "$html_file"
    elif command -v start > /dev/null; then
        start "$html_file"
    else
        echo "Could not find a command to open files"
    fi

# Create new presentation from template
new name:
    @cp template.md "{{name}}.md"
    @echo "Created {{name}}.md"

# Clean output files
clean:
    @rm -f *.html *.pdf *.pptx

# Clean everything including node_modules
cleanup: clean
    @echo "Removing node_modules..."
    @rm -rf node_modules/
    @echo "Removing package-lock.json..."
    @rm -f package-lock.json
    @echo "Cleanup complete. Run 'just install' to reinstall dependencies."

# Build demo presentations
demo:
    @echo "Building demo-standard.md..."
    npx marp --config .marprc.json --html demo-standard.md
    @echo "Building demo-beamer.md..."
    npx marp --config .marprc.json --html demo-beamer.md
    @echo "Demo files built successfully!"

build-open-all:
    #!/usr/bin/env sh
    # Build all files first
    for file in *.md; do
        if [ -f "$file" ]; then
            echo "Building $file..."
            theme=$(if echo "$file" | grep -q "beamer"; then echo "acarp-beamer"; else echo "acarp"; fi)
            npx marp --theme "$theme" --theme-set acarp.css --theme-set acarp-beamer.css --allow-local-files --html "$file"
        fi
    done
    # Then open all HTML files
    echo "Opening all HTML files..."
    for file in *.html; do
        if [ -f "$file" ]; then
            if command -v xdg-open > /dev/null; then
                xdg-open "$file" &
            elif command -v open > /dev/null; then
                open "$file"
            fi
        fi
    done