-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate-my-confluence-how-to-article
executable file
·62 lines (52 loc) · 1.36 KB
/
generate-my-confluence-how-to-article
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
#!/bin/sh
#
# Generate markdown version of my confluence how-to article and push it.
set -e
title=${1:?title missing}
clean_title=$(
printf "$title" |
exec tr -cs '[:alnum:]-' - |
exec tr '[:upper:]' '[:lower:]'
)
: "${clean_title:?invalid title}"
repo=$HOME/src/doc
doc_dir=$repo/how-to-articles
howto_dir=$doc_dir/$clean_title
asset_dir=$howto_dir/asset
pandoc_file=$howto_dir/article.pandoc.md
article_file=$howto_dir/article.md
metadata_file=$howto_dir/metadata.yaml
reference_links_file=$doc_dir/reference-links.pandoc.md
test -r "$asset_dir" &&
test -r "$pandoc_file" &&
test -r "$metadata_file" &&
test -r "$reference_links_file" ||
exit 1
cd -- "$repo" ||
exit 1
export \
GIT_DIR \
GIT_WORK_TREE
GIT_WORK_TREE=$repo
GIT_DIR=$repo/.git
pandoc() {
command pandoc \
-o "$article_file" \
-f markdown \
-t commonmark \
--indented-code-classes numberLines \
"$pandoc_file" \
"$reference_links_file"
# command pandoc \
# -s \
# -o "$article_file.html" \
# -f markdown \
# -t html5 \
# --indented-code-classes numberLines \
# "$metadata_file" "$pandoc_file" "$reference_links_file";
}
\pandoc &&
command -- git add -f "$howto_dir" &&
command -- git commit -m "edit: $title" &&
exec git push -u --tags origin master
# vim: set ft=sh :