Compare commits
No commits in common. "3b9b2217108fcaace3323762040b29a98b6e7432" and "6976b4856f9bf31692a8f0fb8f3e3719deb84ba1" have entirely different histories.
3b9b221710
...
6976b4856f
54
bob
54
bob
@ -108,48 +108,6 @@ publish()
|
|||||||
update_index
|
update_index
|
||||||
}
|
}
|
||||||
|
|
||||||
publish_one()
|
|
||||||
{
|
|
||||||
# Storing the path of the post/article to publish
|
|
||||||
# The path is supposed to have this format "./drafts/published/<article>.*
|
|
||||||
article_path=$1
|
|
||||||
|
|
||||||
# from the relative path, only retrieving the name of the article (without file extension)
|
|
||||||
article_name=$(echo $article_path | cut -d '/' -f 4 | cut -d '.' -f 1)
|
|
||||||
|
|
||||||
# Convert the markdown draft into an html article and storing it locally
|
|
||||||
post=$(awk -f ${BOB_LIB}/markdown.awk ./$article_path)
|
|
||||||
|
|
||||||
# Retrieving the html article template
|
|
||||||
template="${BOB_LIB}/template/post.html"
|
|
||||||
|
|
||||||
# Escaping the & for next step to not confuse awk
|
|
||||||
escaped_post=$(echo "$post" | sed 's/&/\\&/g')
|
|
||||||
|
|
||||||
# In the template, replacing the string {{article}} by the actual content parsed above
|
|
||||||
awk -v content="$escaped_post" '{gsub(/\{\{article\}\}/, content); print}' "$template" > "./posts/$article_name.html"
|
|
||||||
}
|
|
||||||
|
|
||||||
publish_all()
|
|
||||||
{
|
|
||||||
# List all drafts to be published
|
|
||||||
published=$(ls -1 ./drafts/published)
|
|
||||||
|
|
||||||
# turning it into an array
|
|
||||||
published_array=($published)
|
|
||||||
|
|
||||||
# Remove all html articles in case a previously published one was removed
|
|
||||||
rm ./posts/*.html
|
|
||||||
|
|
||||||
# Publish them one by one (ie turning md into html)
|
|
||||||
for file in "${published_array[@]}"; do
|
|
||||||
publish_one ./drafts/published/$file
|
|
||||||
done
|
|
||||||
|
|
||||||
# updating the index.html as new articles are supposedly present and some may be removed
|
|
||||||
update_index
|
|
||||||
}
|
|
||||||
|
|
||||||
unpublish()
|
unpublish()
|
||||||
{
|
{
|
||||||
# storing the path of the article
|
# storing the path of the article
|
||||||
@ -188,7 +146,17 @@ elif [[ "$1" == "usage" ]]; then
|
|||||||
elif [[ "$1" == "init" ]]; then
|
elif [[ "$1" == "init" ]]; then
|
||||||
init
|
init
|
||||||
elif [[ "$1" == "publish" ]]; then
|
elif [[ "$1" == "publish" ]]; then
|
||||||
publish_all
|
if [[ $# -eq 1 ]]; then
|
||||||
|
echo "Usage : bob publish <draft_name>"
|
||||||
|
else
|
||||||
|
publish $2
|
||||||
|
fi
|
||||||
|
elif [[ "$1" == "unpublish" ]]; then
|
||||||
|
if [[ $# -eq 1 ]]; then
|
||||||
|
echo "Usage : bob unpublish <post_name>"
|
||||||
|
else
|
||||||
|
unpublish $2
|
||||||
|
fi
|
||||||
elif [[ "$1" == "deploy" ]]; then
|
elif [[ "$1" == "deploy" ]]; then
|
||||||
deploy
|
deploy
|
||||||
elif [[ "$1" == "help" ]]; then
|
elif [[ "$1" == "help" ]]; then
|
||||||
|
@ -96,10 +96,6 @@ declare -a tests=(
|
|||||||
"paragraph *emphasis* and **strong**"
|
"paragraph *emphasis* and **strong**"
|
||||||
"<p>paragraph <em>emphasis</em> and <strong>strong</strong></p>"
|
"<p>paragraph <em>emphasis</em> and <strong>strong</strong></p>"
|
||||||
|
|
||||||
"Paragraph 3"
|
|
||||||
"paragraph with *one* emphasis and *two* emphasis"
|
|
||||||
"<p>paragraph with <em>one</em> emphasis and <em>two</em> emphasis</p>"
|
|
||||||
|
|
||||||
"Mix Code blocks and paragraphs 1"
|
"Mix Code blocks and paragraphs 1"
|
||||||
$'First paragraph\n\n code block'
|
$'First paragraph\n\n code block'
|
||||||
"<p>First paragraph</p><pre><code>code block</code></pre>"
|
"<p>First paragraph</p><pre><code>code block</code></pre>"
|
||||||
|
Loading…
Reference in New Issue
Block a user