From 1a3b70a67c6d17e14f3ddd773dc2fd7cd5469d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Sun, 25 Oct 2020 08:57:33 +0100 Subject: [PATCH] Fixed bug regarding line cuts. --- sssg.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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