diff --git a/examples/simple/postone.txt b/examples/simple/postone.txt index 4d29ba4..809d43e 100644 --- a/examples/simple/postone.txt +++ b/examples/simple/postone.txt @@ -1,3 +1,3 @@ Post One Title -This is the body of Post One. +This is the body of Post One. \ No newline at end of file diff --git a/generate.sh b/generate.sh index 51652b1..57bdac0 100755 --- a/generate.sh +++ b/generate.sh @@ -3,3 +3,17 @@ set -ex # YOUR CODE HERE + +mkdir -p "$2" + +for post in $1/* +do + + html="$(basename "$post" .txt).html" + + titleField="$(head -n 1 "$post")" + bodyText="$(tail -n 1 "$post")" + + echo "$post" | sed -e 's/{{body}}/'"$bodyText"'/' -e 's/{{title}}/'"$titleField"'/' template.html >> "$2/$html" + +done \ No newline at end of file diff --git a/test_folder/postone.txt b/test_folder/postone.txt new file mode 100644 index 0000000..4d29ba4 --- /dev/null +++ b/test_folder/postone.txt @@ -0,0 +1,3 @@ +Post One Title + +This is the body of Post One. diff --git a/tests/helpers.pyc b/tests/helpers.pyc new file mode 100644 index 0000000..182a448 Binary files /dev/null and b/tests/helpers.pyc differ