From 13e9c8d172b70d95986b9ba1067f7e4e61b705c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Sat, 10 Feb 2024 21:49:34 +0100 Subject: [PATCH] Refactor qsgen2 script to separate the pandoc engine and its options into separate variables. This allows for easier modification and customization of the pandoc command. The changes include: - Assigning the pandoc engine path to the variable. - Assigning the pandoc engine options to the variable. - Modifying the usage of the variable in the and functions to include the . These changes improve the flexibility and maintainability of the script by separating the engine and its options, making it easier to modify and customize the pandoc command. --- qsgen2 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qsgen2 b/qsgen2 index 7038c29..d699fdc 100755 --- a/qsgen2 +++ b/qsgen2 @@ -197,7 +197,8 @@ elif [[ ${generator} == "markdown" ]]; then exit else # Usage: ${engine} ${1} - Where 1 is the file you want parsed - engine="/usr/local/bin/pandoc --from=markdown --to=html" + engine="/usr/local/bin/pandoc" + engine_opts="--from=markdown --to=html" export file_ext="md" fi else @@ -523,7 +524,7 @@ function _pages() { page_title="${page_title#"${page_title%%[![:space:]]*}"}" # Trim leading whitespace break # Exit the loop after finding the first heading fi - done < ${page_content} + done <<< ${page_content} fi if (${debug}) _msg debug "_pages: ${page_title}" @@ -550,7 +551,7 @@ function _pages() { page_content=$( _youtube "${page_content}" ) fi elif [[ ${generator} == "markdown" ]]; then - page_content=$(echo "$page_content" | ${engine}) + page_content=$(echo "$page_content" | ${engine} ${engine_opts}) fi if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl" @@ -685,7 +686,7 @@ function _blogs() { btitle="${btitle#"${btitle%%[![:space:]]*}"}" # Trim leading whitespace break # Exit the loop after finding the first heading fi - done < ${content} + done <<< ${content} fi ingress=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#INGRESS_START\K(.*?)#INGRESS_STOP" | sed "s|\ \#INGRESS_STOP||" | sed "s|^\ ||" ) body=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#BODY_START\K(.*?)#BODY_STOP" | sed "s|\ \#BODY_STOP||" | sed "s|^\ ||" ) @@ -739,7 +740,7 @@ function _blogs() { blog_content=$(_youtube "${blog_content}") fi elif [[ ${generator} == "markdown" ]]; then - blog_content=$(echo "$blog_content" | ${engine}) + blog_content=$(echo "$blog_content" | ${engine} ${engine_opts}) fi # Replace every #tagline in blog_content