improve spacing and comments
This commit is contained in:
parent
aea3ce7422
commit
dd134e2cba
22
notes2web
22
notes2web
@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
[[ "$1" == "--help" ]] && echo "USAGE: $0 [NOTES_DIRECTORY_1 [NOTES_DIRECTORY_2 [...]]]" && exit 0
|
[[ "$1" == "--help" ]] && echo "USAGE: $0 [NOTES_DIRECTORY_1 [NOTES_DIRECTORY_2 [...]]]" && exit 0
|
||||||
|
|
||||||
|
|
||||||
for configpath in "$HOME/.notes2web.conf" "$HOME/.config/notes2web/config" ".notes2web.conf"
|
for configpath in "$HOME/.notes2web.conf" "$HOME/.config/notes2web/config" ".notes2web.conf"
|
||||||
do
|
do
|
||||||
[[ -f "$configpath" ]] && source "$configpath"
|
[[ -f "$configpath" ]] && source "$configpath"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
function _renderarticle {
|
function _renderarticle {
|
||||||
echo "rendering $1"
|
echo "rendering $1"
|
||||||
pandoc\
|
pandoc\
|
||||||
@ -19,12 +21,14 @@ function _renderarticle {
|
|||||||
--mathjax
|
--mathjax
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _adddirtoindex {
|
function _adddirtoindex {
|
||||||
dir="$(dirname "$1")"
|
dir="$(dirname "$1")"
|
||||||
echo "<h2>$(basename "$dir") notes</h2>" >> index.md
|
echo "<h2>$(basename "$dir") notes</h2>" >> index.md
|
||||||
find "$dir" -name '*.md' -exec bash -c "_addarticletoindex '{}'" \;
|
find "$dir" -name '*.md' -exec bash -c "_addarticletoindex '{}'" \;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _addarticletoindex {
|
function _addarticletoindex {
|
||||||
echo "adding $1 to list of notes"
|
echo "adding $1 to list of notes"
|
||||||
pandoc\
|
pandoc\
|
||||||
@ -35,35 +39,43 @@ function _addarticletoindex {
|
|||||||
>> index.md
|
>> index.md
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export -f _renderarticle
|
export -f _renderarticle
|
||||||
export -f _adddirtoindex
|
export -f _adddirtoindex
|
||||||
export -f _addarticletoindex
|
export -f _addarticletoindex
|
||||||
|
|
||||||
#render each markdown file
|
|
||||||
|
#render each markdown file in every folder passed in args
|
||||||
for file in "$@"
|
for file in "$@"
|
||||||
do
|
do
|
||||||
find "$file" -name '*.md' -exec bash -c "_renderarticle '{}'" \;
|
find "$file" -name '*.md' -exec bash -c "_renderarticle '{}'" \;
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# create an intermediate markdown file of links to each article
|
# create an intermediate markdown file of links to each article
|
||||||
echo "---" > index.md
|
echo "---" > index.md
|
||||||
[[ -z "$name" ]] && echo "title: notes" >> index.md || echo "title: ${name}'s notes" >> index.md
|
[[ -z "$name" ]] && echo "title: notes" >> index.md || echo "title: ${name}'s notes" >> index.md
|
||||||
echo "---" >> index.md
|
echo "---" >> index.md
|
||||||
|
|
||||||
|
|
||||||
|
# mark folders to be included in notes2web's index
|
||||||
for file in "$@"
|
for file in "$@"
|
||||||
do
|
do
|
||||||
[[ ! -f "$file" ]] && echo "the presence of this files tells notes2web that it should be added to the notes2web index" > "$file/.2web"
|
[[ ! -f "$file" ]] && echo "the presence of this files tells notes2web that it should be added to the notes2web index" > "$file/.2web"
|
||||||
done
|
done
|
||||||
|
|
||||||
# add articles to index
|
|
||||||
|
# add articles to index and render
|
||||||
find -name '.2web' -exec bash -c "_adddirtoindex '{}'" \;
|
find -name '.2web' -exec bash -c "_adddirtoindex '{}'" \;
|
||||||
|
|
||||||
|
|
||||||
|
echo "copying styles.css to current directory"
|
||||||
|
cp /opt/notes2web/styles.css .
|
||||||
|
|
||||||
|
|
||||||
echo "rendering index.md"
|
echo "rendering index.md"
|
||||||
pandoc\
|
pandoc\
|
||||||
-t html\
|
-t html\
|
||||||
--template /opt/notes2web/templates/index.html\
|
--template /opt/notes2web/templates/index.html\
|
||||||
-o index.html\
|
-o index.html\
|
||||||
"index.md"
|
"index.md"
|
||||||
|
|
||||||
echo "copying styles.css to current directory"
|
|
||||||
cp /opt/notes2web/styles.css .
|
|
||||||
|
Reference in New Issue
Block a user