forked from kerhac/plantuml-markdown-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
md2html
executable file
·40 lines (31 loc) · 937 Bytes
/
md2html
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
#!/usr/bin/env bash
set -e
function rename_markdown_to_html() {
sed -E '/^Ahref CDATA [a-z]+:/! s/^Ahref CDATA (.*)\.(md|markdown)(#.*)?$/Ahref CDATA \1.html\3/ig'
}
function link_readme_to_index() {
if [[ "${LINK_README_TO_INDEX}" != "true" ]]; then
cat
return
fi
sed -E '/^Ahref CDATA [a-z]+:/! s/^Ahref CDATA (.*\/)?README\.html(#.*)?$/Ahref CDATA \1index.html\2/ig'
}
function link_index_html_to_dir() {
if [[ "${LINK_INDEX_TO_DIR}" != "true" ]]; then
cat
return
fi
sed -E '/^Ahref CDATA [a-z]+:/! s/^Ahref CDATA index\.html(#.*)?$/Ahref CDATA .\/\2/ig' |
sed -E '/^Ahref CDATA [a-z]+:/! s/^Ahref CDATA (.*\/)index\.html(#.*)?$/Ahref CDATA \1\2/ig'
}
cat wrap_begin.html
markdown_py \
-q \
-x plantuml_markdown \
-x mdx_partial_gfm 2> >(grep -v '^Successful' >&2) |
hxpipe |
rename_markdown_to_html |
link_readme_to_index |
link_index_html_to_dir |
hxunpipe
cat wrap_end.html