Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __pycache__/
.cache/
output/
report.json
.DS_Store
41 changes: 41 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,44 @@
set -ex

# YOUR CODE HERE
SRC_DIR=$1
DES_DIR=$2

if [ ! -x "$DES_DIR" ];then
mkdir -p "$DES_DIR"
fi

for f in "$SRC_DIR"/*
do
if [ -f "$f" ];then
# line_count=$(cat $SRC_DIR/$f |wc -l)

title=$(head -1 "$f")
lines=$(tail -n 1 "$f" | tr "\n" "\r")
# if [ $line_count -ne 2 ]; then
# lines=`tail -$(($line_count - 2)) $SRC_DIR/$f | tr "\n" "\r"`
# else
# lines=""
# fi

# tmplt=`cat ./template.html | sed "s/{{title}}/$title/"`
# echo $tmplt

# for line in `tail -$(($line_count - 2)) $SRC_DIR/$f`; do
# echo "==="
# echo $tmplt
# tmplt=`echo -e $tmplt | sed "s/{{body}}/$line\n{{body}}/"`
# echo $tmplt
# done

# echo "***"
# echo $tmplt

# echo -e $tmplt | sed "s/{{body}}/""/" > $DES_DIR/$f.html

DEST_FILE=$(basename "$f")
# cat ./template.html | sed "s/{{title}}/$title/; s/{{body}}/$lines/" < ./template.html | tr "\r" "\n" > "$DES_DIR"/"${DEST_FILE%.*}".html
sed "s/{{title}}/$title/; s/{{body}}/$lines/" < ./template.html | tr "\r" "\n" > "$DES_DIR"/"${DEST_FILE%.*}".html
fi
done