summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/compiler
blob: 49c833d5668a58f7782ad348176bb081a817fb26 (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
#!/bin/sh

# Setting Vars
FILE=$(basename "$1")
EXTENSION=$(echo "$FILE" | awk -F . '{if (NF>1) {print $NF}}')
BASE=$(basename "$FILE" ."$EXTENSION")

# Filter to compile other types of files
case $EXTENSION in
	md|rmd)
		FORMAT=$(printf "PDF\nHTML\nBeamer\nODT\nDOCX\nPPTX\n" | dmenu -c -l 15 -i -p "Format:")
		case "$FORMAT" in
			PDF)
				pandoc "$FILE" --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash \
					--output "$BASE".pdf --self-contained --highlight-style tango --pdf-engine pdflatex \
					--variable graphics --variable 'geometry:margin=1in'
				;;
			HTML)
				pandoc "$FILE" --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash \
					--output "$BASE".html --email-obfuscation none --self-contained --standalone --section-divs \
					--template ~/.local/src/templates/default.html --no-highlight --variable highlightjs=1 \
					--variable 'theme:bootstrap' --mathjax
				;;
			Beamer)
				pandoc "$FILE" --to beamer --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".pdf \
					--highlight-style tango --pdf-engine pdflatex --self-contained
				;;
			ODT)
				pandoc "$FILE" --to odt --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".odt
				;;
			DOCX)
				pandoc "$FILE" --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".docx \
					--highlight-style tango
				;;
			PPTX)
				pandoc "$FILE" --to pptx --from markdown+autolink_bare_uris+tex_math_single_backslash --output "$BASE".pptx
		esac
		;;
	ms)
		groff -k -T pdf -m -ms "$FILE" > "$BASE.pdf"
		;;
	java)
		java "$FILE"
		;;
	c|h)
		cc -o "$BASE" ./*.c
esac