diff --git a/sssg.sh b/sssg.sh index 1e1119d..fd993d1 100755 --- a/sssg.sh +++ b/sssg.sh @@ -20,11 +20,11 @@ function parse { echo -n "Generating _site/$1 ... " touch _site/$1 # get the variables - last_find="$(grep -n "^%%%$" $1 | cut -c1)" + last_find="$(grep -n "^%%%$" $1)" vars=() if ! [ -z $last_find ] then - end_line="$(expr $last_find - 1)" + end_line="$(expr ${last_find%%:*} - 1)" for (( i=1; i<=$end_line; i++ )) do vars+=("$(sed "$i!d" $1)") @@ -32,21 +32,22 @@ function parse { fi # import templates - for i in $(grep -n "^#/" $1 | cut -c1) + for i in $(grep -n "^#/" $1) do - end_line="$(expr $i - 1)" + end_line="$(expr ${i%%:*} - 1)" if [ -z $last_find ] then sed -n "1,$end_line{p}" $1 >> _site/$1 else - start_line="$(expr $last_find + 1)" + start_line="$(expr ${last_find%%:*} + 1)" sed -n "$start_line,$end_line{p}" $1 >> _site/$1 fi - inc_file="$(sed "$i!d" $1)" + #inc_file="$(sed "$i!d" $1)" + inc_file=${i#*:} cat _templates/${inc_file:2} >> _site/$1 last_find="$i" done - start_line="$(expr $last_find + 1)" + start_line="$(expr ${last_find%%:*} + 1)" sed -n "$start_line,\$p" $1 >> _site/$1 # replace variables