-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTaskfile.yaml
128 lines (127 loc) · 4.68 KB
/
Taskfile.yaml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
- hosts: myhosts
gather_facts: true
become: true
vars:
cli_provider: bash
template: _template/templates/default.html
docroot: .
curr_dir: $(pwd)
header: ${curr_dir}/_common/templates/header.html
css: ${curr_dir}/_common/templates/default.css
watch_patterns: .*
VERSION_STRING: 19.08.13.26
DELIM: _@DELIM@_
interval: 1
required_parameters:
--source|-s: source ## some/markdown/file.md,some/other/markdown/file2.md,includes/*
--output|-o: output ## some/output/file.html
optional_parameters:
--css|-c: css ## Override default style sheet specification
--template|-t: template ## Override default markdown template
--docroot|-r: docroot ## Override document root
--header|-H: header ## Override header template
--ppvars|-p: ppvars ## Specify extra pre-processor variables
--vars|-V: vars ## Specify extra pandoc variables
--metavars|-m: metavars ## Specify extra meta variables
--watchdir|-wd: watchdir ## Specify the directory for monitoring changes
--patterns|-wp: watch_patterns ## Specify pattern for watch mode, e.g. somefile1.md,somefile2.html,*.txt,*.md,*.js,*.etc
--interval|-i: interval ## Specify interval for watch mode [t>0]
--no-aio: noaio ## Instruct pandoc to not build a self-contained document
--dry: dry_run ## Dry Run, only echo the build command
--watch: build_and_watch ## Invoke the 'build_and_watch' make-style function
help:
message: |
Build a self-contained interactive HTML document
epilog:
examples:
- example1: |
Usage example 1
- example2: |
Usage example 2
functions:
check_exe:
shell: bash
hidden: true
source: |-
echo Checking for ${1} ...
if ! [[ ($(type /usr/{,local/}{,s}bin/${1} 2> /dev/null)) || ($(which ${1})) ]];then
echo "This function requires ${1}, see installation instructions: ${2}"
return 1
fi
build_pp_vars:
shell: bash
help: Build Pre-Processor Vars
hidden: true
source: |-
pp_commands="pp "
if [[ -n $ppvars ]];then
if [[ $ppvars =~ .*${DELIM}.* ]];then
ppvars=${ppvars//${DELIM}/ -D }
pp_commands+="-D ${ppvars: :-3} "
else
pp_commands+="-D $ppvars "
fi
fi
pp_commands+="${source} "
build_pandoc_commands:
shell: bash
help: Build Pre-Processor Vars
hidden: true
source: |-
output_file=${output-${source%.*}.html}
pandoc_commands="pandoc "
pandoc_commands+="-o ${output_file} "
pandoc_commands+="-c ${css} "
pandoc_commands+="-H ${header} "
pandoc_commands+="--template ${template} "
pandoc_commands+="-V VERSION_STRING=${VERSION_STRING} "
if [[ $vars ]];then
vars=${vars//${DELIM}/ -V }
option='-V '
pandoc_commands+="-V ${vars: :-${#option}} " # strip the trailing option
fi
pandoc_commands+="-V docroot=${docroot} "
if [[ $metavars ]];then
metavars=${metavars//${DELIM}/ --metadata }
option="--metadata "
pandoc_commands+="--metadata ${metavars: :-${#option}} " # strip the trailing option
fi
if [[ -n $noaio ]];then
echo Building sans self-contained
else
pandoc_commands+="--self-contained "
pandoc_commands+=" --standalone "
fi
build:
shell: bash
help: Build output file
source: |-
if ! check_exe pandoc https://pandoc.org/installing.html;then
return 1
fi
if ! check_exe pp https://github.com/CDSoft/pp#installation;then
return 1
fi
build_pp_vars
build_pandoc_commands
if [[ -n $dry_run ]];then
echo $PREFIX ${pp_commands} \| ${pandoc_commands}
return
fi
echo "Issuing build"
if ${pp_commands} | ${pandoc_commands};then
echo "Done. Output file is ${output_file}"
else
echo "Build failed."
exit 1
fi
build_and_watch:
shell: bash
help: Build output file and watch for changes
source: |-
build
echo "Watching for changes"
watchmedo shell-command \
--patterns="${watch_patterns}" \
--recursive \
--command="tasks run -s ${source} -o ${output} -t ${template} ---make build"