From bb08f87ec3cd656c747a127b30eb6306cfb42f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Fri, 2 Feb 2024 16:40:20 +0100 Subject: [PATCH] _pages: Ugh, deleted the BODY replacement --- qsgen2 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qsgen2 b/qsgen2 index 8d8660d..d13c34a 100755 --- a/qsgen2 +++ b/qsgen2 @@ -416,11 +416,10 @@ function _pages() { # HTML'ify the page content if (${debug}) _msg debug "_pages: Running engine on ${pages_in_array}" - if [[ ${file_ext} == "tpl" ]]; then + if [[ ${file_ext} == "tpl" ]]; then local page_content=$( ${engine} "$page_content" ) - - # Look for links, images and videos and convert them if present. - if (${debug}) _msg debug "_pages: Checking for #link, #showimg and #ytvideo in page_content" + # Look for links, images and videos and convert them if present. + if (${debug}) _msg debug "_pages: Checking for #link, #showimg and #ytvideo in page_content" if [[ $( echo ${page_content} | grep \#link ) ]]; then if (${debug}) _msg debug "_pages: #link is present, run _link: page_content" local page_content=$( _link "${page_content}" ) @@ -437,6 +436,11 @@ function _pages() { local page_content=$(echo "$page_content" | ${engine}) fi + # Insert page_content into pages_tpl by replacing the BODY tag present there + if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl using Perl" + # Use Perl for multi-line and special character handling + local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") ) + # Replace every #pagetitle in pages_tpl if (${debug}) _msg debug "_pages: Replacing #pagetitle in pages_tpl" local pages_tpl=$( echo ${pages_tpl} | perl -pe "s|#pagetitle|${page_title}|gs" )