mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2025-04-11 08:31:51 +00:00
rework make-html: better messages, more checks
This commit is contained in:
parent
e22fcbf9c3
commit
bbbf57c5d6
@ -1,16 +1,43 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# magic to ensure that we're always inside the root of our application,
|
##############################################################
|
||||||
# no matter from which directory we'll run script
|
#
|
||||||
if [ ! -f README.html ]; then
|
# File: make-html.sh
|
||||||
echo "This script must run where README.html is!" && exit 1
|
#
|
||||||
fi
|
# Description: creates html version from *.md files
|
||||||
|
#
|
||||||
|
# Usage: source make-hmtl
|
||||||
|
#
|
||||||
|
#### $$VERSION$$ v1.21-pre-2-ge22fcbf
|
||||||
|
##############################################################
|
||||||
|
|
||||||
# make html doc
|
# check for correct dir
|
||||||
mkdir html 2>/dev/null
|
if [[ ! ( -f README.html && -f README.md ) ]]; then
|
||||||
cp README.html html/index.html
|
echo "Error: Can't create html, script must run where README.md and README.html is!"
|
||||||
find doc -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "./html/$(basename ${0%.md}.html)"' {} \;
|
|
||||||
if [ -d "examples" ]; then
|
else
|
||||||
find examples -iname "*.md" -type f -exec sh -c 'pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "${0%.md}.html"' {} \;
|
# check if pandoc installed
|
||||||
EXAMPLES="examples"
|
if [ "$(type -t pandoc)" != "file" ]; then
|
||||||
|
echo "pandoc not found, skipping html generation ..."
|
||||||
|
|
||||||
|
else
|
||||||
|
########
|
||||||
|
# everything seems ok, start html generation
|
||||||
|
printf "Start hmtl conversion "
|
||||||
|
# create dir for html doc and index.html there
|
||||||
|
mkdir html 2>/dev/null
|
||||||
|
cp README.html html/index.html
|
||||||
|
# convert *.md files in doc to *.hmtl in html
|
||||||
|
find doc -iname "*.md" -type f -exec sh -c\
|
||||||
|
'printf "."; pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "./html/$(basename ${0%.md}.html)"' {} \;
|
||||||
|
# html for examples dir
|
||||||
|
if [ -d "examples" ]; then
|
||||||
|
EXAMPLES="examples" # add to final conversion job
|
||||||
|
find examples -iname "*.md" -type f -exec sh -c\
|
||||||
|
'printf "."; pandoc -s -f commonmark -M "title=Bashobot Documentation - ${0%.md}.html" "${0}" -o "${0%.md}.html"' {} \;
|
||||||
|
fi
|
||||||
|
# final: convert links from *.md to *.html
|
||||||
|
find README.html html ${EXAMPLES} -iname "*.html" -type f -exec sh -c\
|
||||||
|
'sed -i -E "s/href=\"(\.\.\/)*doc\//href=\"\1html\//g;s/href=\"(.*).md(#.*)*\"/href=\"\1.html\"/g" ${0}' {} \;
|
||||||
|
printf " Done!\n"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
find README.html html ${EXAMPLES} -iname "*.html" -type f -exec sh -c 'sed -i -E "s/href=\"(\.\.\/)*doc\//href=\"\1html\//g;s/href=\"(.*).md(#.*)*\"/href=\"\1.html\"/g" ${0}' {} \;
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user