From 08d20b0550055d6e7dec4df78f3b2dcfc6eda936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Thu, 1 Feb 2024 10:58:18 +0100 Subject: [PATCH] _html: Rewrite the function to use Perl instead of sed. --- qsgen2 | 123 +++++++++++++++++++++++++++------------------------------ 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/qsgen2 b/qsgen2 index b27fef6..8da3846 100755 --- a/qsgen2 +++ b/qsgen2 @@ -797,79 +797,72 @@ function _cleanup() { } function _html() { - - # This function converts formatting tags into their HTML equivalents in a provided string - # using QStags (QS-tags) - + local content="${1}" local debug=false - if (${debug}); then _msg debug "_html: Converting QStags in content"; fi + if ${debug}; then _msg debug "_html: Converting QStags in content"; fi - # Perform HTML tag substitutions handling both lowercase and uppercase QStags - local html_content=$( echo "${content}" | sed \ - -e "s|#[bB][rR]|
\n|g" \ - -e "s|#[bB]||g" \ - -e "s|#[eE][bB]|\n|g" \ - -e "s|#[iI]||g" \ - -e "s|#[eE][iI]||g" \ - -e "s|#[pP]|

|g" \ - -e "s|#[eE][pP]|

\n|g" \ - -e "s|#[hH]1|

|g" \ - -e "s|#[hH]2|

|g" \ - -e "s|#[hH]3|

|g" \ - -e "s|#[hH]4|

|g" \ - -e "s|#[hH]5|

|g" \ - -e "s|#[hH]6|
|g" \ - -e "s|#[eE][hH]1|
\n|g" \ - -e "s|#[eE][hH]2|\n|g" \ - -e "s|#[eE][hH]3|\n|g" \ - -e "s|#[eE][hH]4|\n|g" \ - -e "s|#[eE][hH]5|\n|g" \ - -e "s|#[eE][hH]6|\n|g" \ - -e "s|#[sS][tT][rR][oO][nN][gG]||g" \ - -e "s|#[eE][sS][tT][rR][oO][nN][gG]||g" \ - -e "s|#[eE][mM]||g" \ - -e "s|#[eE][eE][mM]||g" \ - -e "s|#[dD][iI][vV]|
|g" \ - -e "s|#[eE][dD][iI][vV]|
\n|g" \ - -e "s|#[sS][pP][aA][nN]||g" \ - -e "s|#[eE][sS][pP][aA][nN]|\n|g" \ - -e "s|#[uU][lL]|\n\n|g" \ - -e "s|#[eE][oO][lL]|\n\n|g" \ - -e "s|#[eE][lL][iI]|\n|g" \ - -e "s|#[uU]||g" \ - -e "s|#[eE][uU]||g" \ - -e "s|#[tT][aA][bB][lL][eE]||g" \ - -e "s|#[eE][tT][aA][bB][lL][eE]|
\n|g" \ - -e "s|#[tT][rR]||g" \ - -e "s|#[eE][tT][rR]|\n|g" \ - -e "s|#[tT][dD]||g" \ - -e "s|#[eE][tT][dD]|\n|g" \ - -e "s|#[tT][hH]||g" \ - -e "s|#[eE][tT][hH]|\n|g" \ - -e "s|#[aA][rR][tT]|
|g" \ - -e "s|#[eE][aA][rR][tT]|
|g" \ - -e "s|#[sS][eE][cC][tT]|
|g" \ - -e "s|#[eE][sS][eE][cC][tT]|
\n|g" \ - -e "s|#[aA][sS][iI][dD][eE]||g" \ - -e "s|#[nN][aA][vV]|\n|g" \ - -e "s|#[bB][tT][nN]||g" \ - -e "s|#[sS][lL][cC][tT]||g" \ - -e "s|#[oO][pP][tT]||g" ) + # Convert QStags to HTML using Perl + local html_content=$(perl -pe ' + next if /#link|#image|#ytvideo/; + s/(?\n/gi; + s/(?/gi; + s/(?\n/gi; + s/(?/gi; + s/(?/gi; + s/(?/gi; + s/(?\n/gi; + s/(?/gi; + s/(?\n/gi; + s/(?/gi; + s/(?/gi; + s/(?/gi; + s/(?/gi; + s/(?/gi; + s/(?\n/gi; + s/(?/gi; + s/(?\n/gi; + s/(?/gi; + s/(?\n/gi; + s(?/gi; + s/(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s(?/gi; + s(?\n/gi; + s/(?