From 67136642e5eb1f61672ff6500da32e91a5effc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Mon, 12 Feb 2024 20:29:04 +0100 Subject: [PATCH] Refactor _pages function in qsgen2 script to use a while loop to find the page_title. This change allows the function to work with both native and markdown generators. --- qsgen2 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/qsgen2 b/qsgen2 index bca2097..82877b4 100755 --- a/qsgen2 +++ b/qsgen2 @@ -510,11 +510,14 @@ function _pages() { # Grab the title from the Page if (${debug}) _msg debug "_pages: Finding page_title" if [[ ${generator} == "native" ]]; then - # Use Zsh built in functions to find page_title - if [[ "${page_content}" =~ ^#title=(.*) ]]; then - local page_title=$match[1] - #local page_title=$( echo ${page_content} | head -2 | grep \#title | cut -d= -f2 ) - fi + while read -r line + do + if [[ "$line" =~ ^#title=(.*) ]]; then + local page_title=${match[1]} + break + #local page_title=$( echo ${page_content} | head -2 | grep \#title | cut -d= -f2 ) + fi + done <<< "$page_content" elif [[ ${generator} == "markdown" ]]; then while IFS= read -r line do