_html: Ask Perl to parse every and only QStags

This commit is contained in:
Stig-Ørjan Smelror 2024-02-01 11:36:01 +01:00
parent bd545fd139
commit 55e4ff6972

4
qsgen2
View File

@ -803,7 +803,7 @@ function _html() {
if ${debug}; then _msg debug "_html: Converting QStags in content"; fi
# Convert QStags to HTML using Perl, strictly matching the QStags list
local html_content=$(echo "${content}" | perl -pe '
local html_content=$(echo "${content}" | perl -0777 -pe '
BEGIN {
# Define a hash of QStags to their HTML equivalents
%qstags = (
@ -843,7 +843,7 @@ function _html() {
}
while (my ($key, $value) = each %qstags) {
$key = quotemeta($key); # Escape special characters in QStags
s/(?<!\S)$key\b/$value/gi;
s/(?<!\S)\Q$key\E\b/$value/g;
}
');