From 6705bdc69e1682982832ebea24e791581c44d0d2 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Mon, 3 Aug 2026 21:52:33 -0500 Subject: Allow comments to have tabs Currently, comments need to be left-aligned, even if they appear in an indented block. change the comment form to strip the same whitespace as the first line so that comments can be indented without embedding indents in the stdin. --- tests/helpers/common.bash | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'tests/helpers/common.bash') diff --git a/tests/helpers/common.bash b/tests/helpers/common.bash index 779cc96..12501bc 100644 --- a/tests/helpers/common.bash +++ b/tests/helpers/common.bash @@ -64,9 +64,18 @@ BEGIN{} /\*\// { if(in_comment) {print "EOF"} in_comment=0 + indent="" +} +in_comment { + line=\$0 + if (indent != "" && index(line, indent) == 1) { + line=substr(line, length(indent)+1) + } + print line } -in_comment {print} /\/\* .+/ && !/\*\// { + indent=\$0 + sub(/[^[:space:]].*/, "", indent) print "chunkfile=\$(mktemp -p ${cache}/chunks)" print "cat > \$chunkfile << \"EOF\"\\n@file " name ":" NR ; if(\$2) {\$1=""; print "@exec " \$0} @@ -83,9 +92,18 @@ BEGIN{} /\]\]/ { if(in_comment) {print "EOF"} in_comment=0 + indent="" +} +in_comment { + line=\$0 + if (indent != "" && index(line, indent) == 1) { + line=substr(line, length(indent)+1) + } + print line } -in_comment {print} /--\[\[ .+/ && !/\]\]$/ { + indent=\$0 + sub(/[^[:space:]].*/, "", indent) print "chunkfile=\$(mktemp -p ${cache}/chunks)" print "cat > \$chunkfile << \"EOF\"\\n@file " name ":" NR ; if(\$2) {\$1=""; print "@exec " \$0} @@ -103,9 +121,18 @@ BEGIN{} /'''/ { if(in_comment) {print "EOF"} in_comment=0 + indent="" +} +in_comment { + line=$0 + if (indent != "" && index(line, indent) == 1) { + line=substr(line, length(indent)+1) + } + print line } -in_comment {print} /'''.+/ && !/'''$/ { + indent=$0 + sub(/[^[:space:]].*/, "", indent) print "chunkfile=$(mktemp -p __PY_CACHE__/chunks)" print "cat > $chunkfile << \"EOF\"\n@file " name ":" NR ; renderer = $0 -- cgit v1.2.3-70-g09d2