Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Open

try #66

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
32 changes: 30 additions & 2 deletions generate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
#!/bin/bash

set -ex
FILES="$1/*.txt"
DEST=$2
mkdir -p "$DEST"
for f in $FILES
do
# echo "Processing $f file..."
# take action on each file. $f store current file name
# cat $f

# YOUR CODE HERE
# Parsing doc
headerline=$(head -1 "$f")
restofdoc=$(tail -n +3 "$f")
# end of parsing doc
filename=$(basename "$f")
filename="${filename%.*}"
# Copy html file
cp template.html "$DEST"/"$filename".html

# Replace
/bin/sed -i "s/{{title}}/${headerline}/" "$DEST"/"$filename".html
/bin/sed -i -e "s|{{body}}|$restofdoc|g" "$DEST"/"$filename".html
/bin/sed -i -e "s|https[:]//[^ ]*.com|<a href=\"\0\">\0</a>|g" "$DEST"/"$filename".html
# /bin/sed -i -e "s|(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?|url|g" "$DEST"/"$filename".html

done
#cat template.html

# ls Desktop\Dropbox\CT\Sys\startup-systems\vm\static
# ./generate.sh examples/simple/ output/
# Always have to run: sed -i 's/\r$//' testscript
# for dos2unix