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.
This commit is contained in:
Stig-Ørjan Smelror 2024-02-10 21:49:34 +01:00
parent 12f36071df
commit 13e9c8d172

11
qsgen2
View File

@ -197,7 +197,8 @@ elif [[ ${generator} == "markdown" ]]; then
exit exit
else else
# Usage: ${engine} ${1} - Where 1 is the file you want parsed # 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" export file_ext="md"
fi fi
else else
@ -523,7 +524,7 @@ function _pages() {
page_title="${page_title#"${page_title%%[![:space:]]*}"}" # Trim leading whitespace page_title="${page_title#"${page_title%%[![:space:]]*}"}" # Trim leading whitespace
break # Exit the loop after finding the first heading break # Exit the loop after finding the first heading
fi fi
done < ${page_content} done <<< ${page_content}
fi fi
if (${debug}) _msg debug "_pages: ${page_title}" if (${debug}) _msg debug "_pages: ${page_title}"
@ -550,7 +551,7 @@ function _pages() {
page_content=$( _youtube "${page_content}" ) page_content=$( _youtube "${page_content}" )
fi fi
elif [[ ${generator} == "markdown" ]]; then elif [[ ${generator} == "markdown" ]]; then
page_content=$(echo "$page_content" | ${engine}) page_content=$(echo "$page_content" | ${engine} ${engine_opts})
fi fi
if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl" 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 btitle="${btitle#"${btitle%%[![:space:]]*}"}" # Trim leading whitespace
break # Exit the loop after finding the first heading break # Exit the loop after finding the first heading
fi fi
done < ${content} done <<< ${content}
fi fi
ingress=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#INGRESS_START\K(.*?)#INGRESS_STOP" | sed "s|\ \#INGRESS_STOP||" | sed "s|^\ ||" ) 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|^\ ||" ) 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}") blog_content=$(_youtube "${blog_content}")
fi fi
elif [[ ${generator} == "markdown" ]]; then elif [[ ${generator} == "markdown" ]]; then
blog_content=$(echo "$blog_content" | ${engine}) blog_content=$(echo "$blog_content" | ${engine} ${engine_opts})
fi fi
# Replace every #tagline in blog_content # Replace every #tagline in blog_content