_qstags: Let's try a simpler substitution for speed

This commit is contained in:
Stig-Ørjan Smelror 2024-02-24 19:32:44 +01:00
parent d3ccb64a73
commit 81b22db011

18
qsgen2
View File

@ -1284,13 +1284,17 @@ function _qstags() {
"#LT" "<" "#GT" ">" "#NUM" "#"
)
for qstag html (${(kv)qstags})
do
# Escape tag for regex use
local escapedTag=$(printf '%s' "$qstag" | sed 's/[].\[^$*]/\\&/g')
if [[ "$content" =~ "$escapedTag" ]]; then
content=${content//($qstag)/$html}
fi
#for qstag html (${(kv)qstags})
# do
# # Escape tag for regex use
# local escapedTag=$(printf '%s' "$qstag" | sed 's/[].\[^$*]/\\&/g')
# if [[ "$content" =~ "$escapedTag" ]]; then
# content=${content//($qstag)/$html}
# fi
#done
for qstag html (${(kv)qstags}); do
# Direct replacement without regex check
content=${content//${qstag}/${html}}
done
echo "${content}"