2022-02-17 17:21:35 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# file: gsl__post_makers
|
|
|
|
# Folder: /var/lib/gsl/scripts
|
|
|
|
# By echolib
|
|
|
|
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# ---------
|
|
|
|
# MAIN CALL
|
|
|
|
# ---------
|
|
|
|
#=======================================================================
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# From: gsl__loop_posts | Convert Post from modules to HTML
|
|
|
|
#=======================================================================
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl__all_makers() {
|
2022-02-19 18:17:09 +01:00
|
|
|
clear
|
|
|
|
unset gsl_check_done
|
|
|
|
gsl__prepare_makers
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__make_strongs
|
|
|
|
gsl__make_bolds
|
|
|
|
gsl__do_header make "$gsl_marker_link" "$gsl_tmp_post"
|
|
|
|
gsl__do_header make "$gsl_marker_abbr" "$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl__make_titles
|
2022-02-27 19:16:16 +01:00
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl_ct=0 && gsl__make_titles_div_open
|
|
|
|
gsl_ct=0 && gsl__make_titles_div_close
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
#echo -ne "\r\033[2K: Searching and converting lists..."
|
|
|
|
#gsl__make_lists
|
2022-02-21 17:25:08 +01:00
|
|
|
echo -ne "\r\033[2K: Searching and converting Paragraphs..."
|
|
|
|
gsl__make_paragraphs
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
#echo -ne "\r\033[2K: Searching and converting Inline-Codes..."
|
|
|
|
#gsl__make_inline_codes
|
|
|
|
#echo -ne "\r\033[2K: Searching and converting Block-Codes..."
|
|
|
|
#gsl__check_bcodes
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
gsl__check_cites
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl__make_a11y
|
|
|
|
echo -ne "\r\033[2K"
|
|
|
|
|
|
|
|
# No more Needed tmp file post
|
|
|
|
rm -f "$gsl_tmp_post"
|
|
|
|
|
|
|
|
# Create HTML Page using gsl_a11y_post
|
|
|
|
clear
|
|
|
|
cat "$gsl_a11y_post"
|
|
|
|
gsl__page_creator
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# No more Needed a11y post
|
|
|
|
rm -f "$gsl_a11y_post"
|
2022-02-19 18:17:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# ---------------------------------------------
|
|
|
|
# Tools and prepapre tmp file from CONTENT Post
|
|
|
|
# ---------------------------------------------
|
|
|
|
#=======================================================================
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Get line nbr from TMP CONTENT Post... $1: TERM | $2: File
|
|
|
|
#=======================================================================
|
|
|
|
gsl__get_mark_content_line() {
|
|
|
|
awk -v s="$1" \
|
|
|
|
'$0 ~ s {print NR}' \
|
|
|
|
"$2" || return
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Get NEEDED infos, and create TMP file from CONTENT
|
|
|
|
#=======================================================================
|
|
|
|
gsl__prepare_makers() {
|
|
|
|
# Getting NEEDED infos
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl_post_type=`
|
|
|
|
awk -F"$gsl_marker_type" '{print $2}' "$gsl_post"`
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
gsl_post_begin=`
|
|
|
|
grep -n "#1" $gsl_post \
|
|
|
|
| head -1 \
|
|
|
|
| awk -F: '{print $1}'`
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# Source config website (DATAS)
|
2022-02-19 18:17:09 +01:00
|
|
|
source "$gsl_this_conf_domain/$gsl_find_domain.conf"
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# Get Needed Headers DATAS
|
|
|
|
gsl__get_needed_headers
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# Get extra Headers DATAS
|
|
|
|
gsl_header_images=`gsl__get_header "$gsl_marker_image" "$gsl_post"`
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# Create TMP file from CONTENT
|
|
|
|
gsl_tmp_post=`mktemp`
|
2022-02-19 18:17:09 +01:00
|
|
|
awk -v l="$gsl_post_begin" \
|
|
|
|
'NR >= l' \
|
|
|
|
"$gsl_post" \
|
2022-02-27 19:16:16 +01:00
|
|
|
> "$gsl_tmp_post"
|
|
|
|
|
|
|
|
# Code readability a11y
|
|
|
|
gsl_a11y_post=`mktemp`
|
2022-02-19 18:17:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# ---------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
# Converters
|
2022-02-19 18:17:09 +01:00
|
|
|
# ---------------------------------
|
|
|
|
#=======================================================================
|
2022-02-27 19:16:16 +01:00
|
|
|
#======================================================================
|
|
|
|
# From gsl__do_header: Make Link
|
|
|
|
#======================================================================
|
|
|
|
gsl__make_link() {
|
|
|
|
echo -ne "\r\033[2K: Converting Links... $gsl_post_hf_1"
|
|
|
|
|
|
|
|
gsl_post_hf_1="${gsl_post_hf_1}"
|
|
|
|
gsl_post_hf_1_t="${gsl_post_hf_1}+"
|
|
|
|
|
|
|
|
[[ "$sl_post_hf_3" ]] \
|
|
|
|
&& gsl_html_link_title=" title=\"$sl_post_hf_3\""
|
|
|
|
|
|
|
|
# target blank
|
|
|
|
gsl_html_link_t=`
|
|
|
|
printf '%s%s%s%s' \
|
|
|
|
"<a href=\"$gsl_post_hf_2\"$gsl_html_link_title " \
|
|
|
|
"targt=\"blank\">" \
|
|
|
|
"$gsl_post_hf_1" \
|
|
|
|
"</a>"`
|
|
|
|
sed -i "s|_${gsl_post_hf_1_t}|$gsl_html_link_t|g" "$gsl_tmp_post"
|
|
|
|
|
|
|
|
# No Target
|
|
|
|
gsl_html_link=`
|
|
|
|
printf '%s%s%s' \
|
|
|
|
"<a href=\"$gsl_post_hf_2\"$gsl_html_link_title>" \
|
|
|
|
"$gsl_post_hf_1" \
|
|
|
|
"</a>"`
|
|
|
|
sed -i "s|_${gsl_post_hf_1}|$gsl_html_link|g" "$gsl_tmp_post"
|
|
|
|
}
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
# From gsl__do_header: Make ABBRS
|
|
|
|
#======================================================================
|
|
|
|
gsl__make_abbr() {
|
|
|
|
echo -ne "\r\033[2K: Converting ABBRs... $gsl_post_hf_1"
|
|
|
|
|
|
|
|
gsl_html_long="<abbr title=\"$gsl_post_hf_2\">$gsl_post_hf_1</abbr>"
|
|
|
|
sed -i "s|$gsl_post_hf_1|$gsl_html_long|" "$gsl_tmp_post"
|
|
|
|
}
|
|
|
|
|
|
|
|
gsl_make_sb_show() {
|
|
|
|
echo -ne "\r\033[2K: Converting... Line:$gsl_line_nbr $gsl_html_word"
|
|
|
|
sed -i "s|$gsl_word_replace|$gsl_html_word|" "$gsl_tmp_post"
|
|
|
|
unset ${!gsl_word@} ${!gsl_html@}
|
|
|
|
}
|
|
|
|
#======================================================================
|
|
|
|
# From gsl__all_header: Make Strongs
|
|
|
|
#======================================================================
|
|
|
|
gsl__make_strongs() {
|
|
|
|
while read -r "gsl_line_nbr" "gsl_word"
|
|
|
|
do
|
|
|
|
case "$gsl_word" in
|
|
|
|
# STRONG
|
|
|
|
"**"*"**"*|*"**"*"**"*)
|
|
|
|
gsl_word=${gsl_word#*'**'}
|
|
|
|
gsl_word=${gsl_word%'**'*}
|
|
|
|
gsl_word_replace='\*\*'"$gsl_word"'\*\*'
|
|
|
|
gsl_html_word="<strong>$gsl_word</strong>"
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
"**"*"**")
|
|
|
|
gsl_html_word="<strong>${gsl_word//'**'/}</strong>"
|
|
|
|
gsl_word_replace='\*\*'"$gsl_word"'\*\*'
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
"**"*)
|
|
|
|
gsl_word=${gsl_word#'**'*}
|
|
|
|
gsl_html_word="<strong>$gsl_word"
|
|
|
|
gsl_word_replace='\*\*'"$gsl_word"
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
*"**")
|
|
|
|
gsl_word=${gsl_word%'**'*}
|
|
|
|
gsl_html_word="${gsl_word//'**'/}</strong>"
|
|
|
|
gsl_word_replace="$gsl_word"'\*\*'
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < <(awk '{for(i=1;i<=NF;i++) {print NR, $i}}' "$gsl_tmp_post")
|
|
|
|
}
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
# From gsl__all_header: Make Bolds
|
|
|
|
#======================================================================
|
|
|
|
gsl__make_bolds() {
|
|
|
|
while read -r "gsl_line_nbr" "gsl_word"
|
|
|
|
do
|
|
|
|
case "$gsl_word" in
|
|
|
|
# STRONG
|
|
|
|
"*"*"*"*|*"*"*"*"*)
|
|
|
|
gsl_word=${gsl_word#*'*'}
|
|
|
|
gsl_word=${gsl_word%'*'*}
|
|
|
|
gsl_word_replace='\*'"$gsl_word"'\*'
|
|
|
|
gsl_html_word="<b>$gsl_word</b>"
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
"*"*"*")
|
|
|
|
gsl_html_word="<b>${gsl_word//'*'/}</b>"
|
|
|
|
gsl_word_replace='\*'"$gsl_word"'\*'
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
"*"*)
|
|
|
|
gsl_word=${gsl_word#'*'*}
|
|
|
|
gsl_html_word="<b>$gsl_word"
|
|
|
|
gsl_word_replace='\*'"$gsl_word"
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
*"*")
|
|
|
|
gsl_word=${gsl_word%'*'*}
|
|
|
|
gsl_html_word="${gsl_word//'*'/}</b>"
|
|
|
|
gsl_word_replace="$gsl_word"'\*'
|
|
|
|
gsl_make_sb_show
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < <(awk '{for(i=1;i<=NF;i++) {print NR, $i}}' "$gsl_tmp_post")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Find BLOCK-CODES
|
|
|
|
#=======================================================================
|
|
|
|
gsl__check_bcodes() {
|
|
|
|
gsl_lines_nbr=(`
|
|
|
|
gsl__get_mark_content_line \
|
|
|
|
"$gsl_mark_code" \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post"`)
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
|
|
! [[ "$gsl_lines_nbr" ]] \
|
|
|
|
&& return
|
|
|
|
|
|
|
|
for i in `seq 1 ${#gsl_lines_nbr[@]}`
|
|
|
|
do
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl__make_bcode
|
2022-02-19 18:17:09 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Find BLOCKQUOTES
|
|
|
|
#=======================================================================
|
|
|
|
gsl__check_cites() {
|
2022-02-27 19:16:16 +01:00
|
|
|
echo -ne "\r\033[2K: Searching and converting Citations..."
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
unset gsl_lines_nbr
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
gsl_lines_nbr=(`
|
|
|
|
gsl__get_mark_content_line \
|
2022-02-21 17:25:08 +01:00
|
|
|
"$gsl_mark_blockquote" \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post"`)
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl_lines_nbr=(${gsl_lines_nbr[0]} ${gsl_lines_nbr[1]})
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
|
|
! [[ "$gsl_lines_nbr" ]] \
|
|
|
|
&& return
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
for i in `seq 1 ${#gsl_lines_nbr[@]}`
|
|
|
|
do
|
|
|
|
if [[ "$gsl_cite_start" ]];then
|
|
|
|
unset gsl_cite_start
|
|
|
|
gsl_cite_line_stop=${gsl_lines_nbr[(($i-1))]}
|
|
|
|
gsl__make_cite
|
|
|
|
else
|
|
|
|
gsl_cite_start=true
|
|
|
|
gsl_cite_line_start=${gsl_lines_nbr[(($i-1))]}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
gsl__check_cites
|
2022-02-19 18:17:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# -----------------------------------------------
|
|
|
|
# Convert To HTML in duplicated CONTENT Post File
|
|
|
|
# -----------------------------------------------
|
|
|
|
#=======================================================================
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
#=======================================================================
|
|
|
|
# Find and convert Titles #1-6
|
|
|
|
#=======================================================================
|
|
|
|
gsl__make_titles() {
|
2022-02-27 19:16:16 +01:00
|
|
|
echo -ne ": Searching and converting Titles..."
|
|
|
|
for t in `seq 1 6`
|
2022-02-21 17:25:08 +01:00
|
|
|
do
|
2022-02-27 19:16:16 +01:00
|
|
|
while read -r "h" "content"
|
2022-02-21 17:25:08 +01:00
|
|
|
do
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl_html_title="<h$t>$content</h$t>"
|
|
|
|
sed -i "s^$h $content^$gsl_html_title^" \
|
|
|
|
"$gsl_tmp_post"
|
|
|
|
done < <(grep "#$t" "$gsl_tmp_post")
|
|
|
|
done
|
2022-02-21 17:25:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#=======================================================================
|
|
|
|
# Open DIVs after titles for css
|
|
|
|
#=======================================================================
|
|
|
|
gsl__make_titles_div_open() {
|
2022-02-27 19:16:16 +01:00
|
|
|
echo -ne "\r\033[2K: Searching Titles and Open DIVs..."
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl_ct=$(( gsl_ct + 1 ))
|
|
|
|
gsl_content_title=`
|
2022-02-27 19:16:16 +01:00
|
|
|
grep -n "<h" "$gsl_tmp_post" \
|
2022-02-21 17:25:08 +01:00
|
|
|
| head -n $gsl_ct \
|
|
|
|
| tail -n 1`
|
|
|
|
|
|
|
|
[[ "$gsl_content_title" == "$gsl_content_same_title" ]] && return
|
|
|
|
! [[ "$gsl_content_title" ]] && return
|
|
|
|
|
|
|
|
gsl_content_line_nbr=`
|
|
|
|
awk -F: '{print $1}' \
|
|
|
|
<<< $gsl_content_title`
|
|
|
|
gsl_title_n=`
|
|
|
|
awk -F"<h" '{print $2}' \
|
|
|
|
<<< "$gsl_content_title" \
|
|
|
|
| awk -F">" '{print $1}'`
|
|
|
|
|
|
|
|
|
|
|
|
gsl_html_div="<div class=\"${gsl_site_css}_content-p$gsl_title_n\">"
|
|
|
|
sed -i "$(( $gsl_content_line_nbr + 1 ))i$gsl_html_div" \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
|
|
gsl_content_same_title="$gsl_content_title"
|
|
|
|
gsl__make_titles_div_open
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Close DIVs before titles for css
|
|
|
|
#=======================================================================
|
|
|
|
gsl__make_titles_div_close() {
|
2022-02-27 19:16:16 +01:00
|
|
|
echo -ne "\r\033[2K: Searching Titles and Open DIVs..."
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl_test_line="<div class=\"${gsl_site_css}_content"
|
|
|
|
|
|
|
|
gsl_ct=$(( gsl_ct + 1 ))
|
|
|
|
gsl_content_title=`
|
2022-02-27 19:16:16 +01:00
|
|
|
grep -n "$gsl_test_line" "$gsl_tmp_post" \
|
2022-02-21 17:25:08 +01:00
|
|
|
| head -n $gsl_ct \
|
|
|
|
| tail -n 1`
|
|
|
|
|
|
|
|
[[ "$gsl_content_title" == "$gsl_content_same_title" ]] \
|
2022-02-27 19:16:16 +01:00
|
|
|
&& echo "</div>" >> "$gsl_tmp_post" \
|
2022-02-21 17:25:08 +01:00
|
|
|
&& return
|
|
|
|
! [[ "$gsl_content_title" ]] && return
|
|
|
|
|
|
|
|
gsl_content_line_nbr=`
|
|
|
|
awk -F: '{print $1}' \
|
|
|
|
<<< $gsl_content_title`
|
|
|
|
|
|
|
|
while read -r "gsl_search_line_nbr" "gsl_search_line"
|
|
|
|
do
|
|
|
|
case "$gsl_search_line" in
|
|
|
|
"<h"*)
|
2022-02-27 19:16:16 +01:00
|
|
|
sed -i "${gsl_search_line_nbr}i</div>" "$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
*) continue ;;
|
|
|
|
esac
|
|
|
|
done < <(awk -v l="$gsl_content_line_nbr" \
|
|
|
|
'NR > l {print NR,$0}' \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post")
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
|
|
gsl_content_same_title="$gsl_content_title"
|
|
|
|
gsl__make_titles_div_close
|
|
|
|
}
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Find and convert paragraphs (3 different css styles)
|
|
|
|
#=======================================================================
|
|
|
|
gsl__make_paragraphs() {
|
|
|
|
gsl_html_par_o1="<p class=\"${gsl_site_css}_paragraph\">"
|
|
|
|
gsl_html_par_o2="<p class=\"${gsl_site_css}_paragraph-2\">"
|
|
|
|
gsl_html_par_o3="<p class=\"${gsl_site_css}_paragraph-3\">"
|
|
|
|
gsl_html_par_c="</p>"
|
|
|
|
|
|
|
|
while read -r "gsl_content_line_nbr" "gsl_content_line"
|
|
|
|
do
|
|
|
|
case "$gsl_content_line" in
|
|
|
|
")")
|
|
|
|
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_c," \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
;;
|
|
|
|
"("|"( 1")
|
|
|
|
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o1," \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
;;
|
|
|
|
"( 2")
|
|
|
|
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o2," \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
;;
|
|
|
|
"( 3")
|
|
|
|
sed -i "${gsl_content_line_nbr}s,.*,$gsl_html_par_o3," \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
2022-02-27 19:16:16 +01:00
|
|
|
done < <(cat -n "$gsl_tmp_post")
|
2022-02-21 17:25:08 +01:00
|
|
|
}
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
#=======================================================================
|
|
|
|
# Replace gsl_mark_code
|
|
|
|
#=======================================================================
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl__make_bcode() {
|
2022-02-19 18:17:09 +01:00
|
|
|
# Get mark line nbr
|
|
|
|
gsl_line_nbr=`
|
|
|
|
gsl__get_mark_content_line \
|
|
|
|
"$gsl_mark_code" \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post" | head -1`
|
2022-02-19 18:17:09 +01:00
|
|
|
|
|
|
|
#---------
|
|
|
|
# Convert
|
|
|
|
#---------
|
|
|
|
gsl_css_class="${gsl_site_css}_block-code"
|
|
|
|
gsl_header_content_line=`gsl__get_header "$gsl_marker_code" "$gsl_post"`
|
|
|
|
gsl_file_tmp_code=`mktemp`
|
|
|
|
|
|
|
|
# Set gsl_post_header_field_1 gsl_post_header_field_2
|
|
|
|
gsl__get_header_fields "$gsl_marker_code"
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
# Create tmp file from block-code, adding span to get number lines in css
|
|
|
|
gsl_file_bcode=`mktemp`
|
|
|
|
while read -r "gsl_bcode_line"
|
|
|
|
do
|
|
|
|
echo "<span>$gsl_bcode_line</span>" >> "$gsl_file_bcode"
|
|
|
|
done < <(cat "$gsl_dir_domain_files/$gsl_post_header_field_2")
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
printf '%s %s\n%b\n%s\n' \
|
|
|
|
"<pre class=\"$gsl_css_class" \
|
|
|
|
"${gsl_css_class}-$gsl_post_header_field_1\">" \
|
2022-02-21 17:25:08 +01:00
|
|
|
"$(cat "$gsl_file_bcode")" \
|
2022-02-19 18:17:09 +01:00
|
|
|
"</pre>" \
|
|
|
|
> "$gsl_file_tmp_code"
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
sed -i "${gsl_line_nbr}r $gsl_file_tmp_code" "$gsl_tmp_post"
|
|
|
|
sed -i "${gsl_line_nbr}d" "$gsl_tmp_post"
|
2022-02-19 18:17:09 +01:00
|
|
|
rm -f "$gsl_file_tmp_code"
|
2022-02-21 17:25:08 +01:00
|
|
|
rm -f "$gsl_file_bcode"
|
2022-02-19 18:17:09 +01:00
|
|
|
}
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
#-----------------------------------------------------------------------
|
2022-02-19 18:17:09 +01:00
|
|
|
#=======================================================================
|
2022-02-21 17:25:08 +01:00
|
|
|
# Replace and Convert this blockquote
|
2022-02-19 18:17:09 +01:00
|
|
|
#=======================================================================
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl__make_cite() {
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl_file_tmp_cite=`mktemp` # File to Put whole Blockquote
|
|
|
|
gsl_file_tmp_cite_content=`mktemp` # File to Put Blockquote CONTENT only
|
|
|
|
gsl_file_tmp_cite_html=`mktemp` # File to Put final HTML blockquote
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
# Put whole blockquote in file
|
2022-02-19 18:17:09 +01:00
|
|
|
awk -v o="$gsl_cite_line_start" -v c="$gsl_cite_line_stop" \
|
|
|
|
'NR >= o && NR <= c' \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_tmp_post" \
|
2022-02-19 18:17:09 +01:00
|
|
|
> "$gsl_file_tmp_cite"
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
# No more DATAS needed for next if any
|
|
|
|
unset ${!gsl_bq_@} ${!gsl_html_cite_@}
|
|
|
|
|
|
|
|
# Get DATAS from blockquote
|
2022-02-19 18:17:09 +01:00
|
|
|
while read -r "gsl_content_line"
|
|
|
|
do
|
|
|
|
case "$gsl_content_line" in
|
|
|
|
---*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
_cite*)
|
|
|
|
gsl_bq_author=`awk -F" : " '{print $2}' <<< "$gsl_content_line"`
|
|
|
|
;;
|
|
|
|
_book*)
|
|
|
|
gsl_bq_book=`awk -F" : " '{print $2}' <<< "$gsl_content_line"`
|
|
|
|
;;
|
|
|
|
_lang*)
|
|
|
|
gsl_bq_lang=`awk -F" : " '{print $2}' <<< "$gsl_content_line"`
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl_html_cite_lang=" lang=\"$gsl_bq_lang\""
|
2022-02-19 18:17:09 +01:00
|
|
|
;;
|
|
|
|
_year*)
|
|
|
|
gsl_bq_year=`awk -F" : " '{print $2}' <<< "$gsl_content_line"`
|
|
|
|
;;
|
|
|
|
_link*)
|
|
|
|
gsl_bq_link=`awk -F" : " '{print $2}' <<< "$gsl_content_line"`
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl_html_cite_link=" cite=\"$gsl_bq_link\""
|
2022-02-19 18:17:09 +01:00
|
|
|
;;
|
|
|
|
*)
|
2022-02-21 17:25:08 +01:00
|
|
|
[[ "$gsl_bq_author" ]] \
|
|
|
|
&& echo " $gsl_content_line" >> "$gsl_file_tmp_cite_content" \
|
|
|
|
|| echo " $gsl_content_line" >> "$gsl_file_tmp_cite_content"
|
2022-02-19 18:17:09 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < <(cat "$gsl_file_tmp_cite")
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
[[ "$gsl_bq_book" ]] \
|
|
|
|
&& gsl_bq_ref=" - $gsl_bq_book"
|
|
|
|
|
|
|
|
[[ "$gsl_bq_year" ]] \
|
|
|
|
&& gsl_bq_ref+=" ($gsl_bq_year)"
|
|
|
|
|
|
|
|
[[ "$gsl_bq_book" ]] \
|
|
|
|
&& gsl_html_cite_book=" title=\"Book:$gsl_bq_ref\""
|
|
|
|
|
|
|
|
! [[ "$gsl_bq_link" ]] && [[ "$gsl_bq_book" ]] \
|
|
|
|
&& gsl_html_cite_link=" cite=\"$gsl_bq_book$gsl_bq_year\""
|
|
|
|
|
|
|
|
rm -f "$gsl_file_tmp_cite" # No more whole blockquote file needed
|
|
|
|
gsl_file_tmp_cite=`mktemp` # File to put Converted HTML DATAS
|
|
|
|
|
|
|
|
# Advanced or simple blockquote
|
|
|
|
[[ "$gsl_bq_author" ]] \
|
|
|
|
&& gsl__make_cite_advanced \
|
|
|
|
|| gsl__make_cite_simple
|
|
|
|
|
|
|
|
# Insert html blockquote file in Post
|
2022-02-27 19:16:16 +01:00
|
|
|
sed -i "${gsl_cite_line_stop}r $gsl_file_tmp_cite_html" "$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
|
|
# Remove useless lines
|
|
|
|
gsl_cite_total_lines=$(( $gsl_cite_line_stop - gsl_cite_line_start ))
|
|
|
|
for i in `seq 0 $gsl_cite_total_lines`
|
|
|
|
do
|
2022-02-27 19:16:16 +01:00
|
|
|
sed -i "${gsl_cite_line_start}d" "$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
rm -f "$gsl_file_tmp_cite_content" # No more blockquote CONTENT needed
|
|
|
|
rm -f "$gsl_file_tmp_cite_html" # No more html blockquote file needed
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# from gsl__post_maker_cite : ADVANCED blockquote
|
|
|
|
#=======================================================================
|
|
|
|
gsl__make_cite_advanced() {
|
|
|
|
gsl_css_class="class=\"${gsl_site_css}_quote\""
|
|
|
|
|
2022-02-19 18:17:09 +01:00
|
|
|
cat << EOCITE > "$gsl_file_tmp_cite_html"
|
|
|
|
<figure>
|
|
|
|
<blockquote $gsl_css_class$gsl_html_cite_lang$gsl_html_cite_link>
|
|
|
|
$(cat "$gsl_file_tmp_cite_content")
|
|
|
|
</blockquote>
|
|
|
|
<figcaption class="a-lec_fgc-quote">
|
|
|
|
<cite>
|
2022-02-21 17:25:08 +01:00
|
|
|
<a href="$gsl_bq_link" target="_blank"$gsl_html_cite_book>$gsl_bq_author</a>$gsl_bq_ref
|
2022-02-19 18:17:09 +01:00
|
|
|
</cite>
|
|
|
|
</figcaption>
|
|
|
|
</figure>
|
|
|
|
EOCITE
|
2022-02-21 17:25:08 +01:00
|
|
|
}
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
#=======================================================================
|
|
|
|
# from gsl__post_maker_cite : SIMPLE blockquote
|
|
|
|
#=======================================================================
|
|
|
|
gsl__make_cite_simple() {
|
|
|
|
gsl_css_class="${gsl_site_css}_simple-quote"
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
cat << EOCITE > "$gsl_file_tmp_cite_html"
|
|
|
|
<blockquote $gsl_css_class$gsl_html_cite_lang$gsl_html_cite_link>
|
|
|
|
$(cat "$gsl_file_tmp_cite_content")
|
|
|
|
</blockquote>
|
|
|
|
EOCITE
|
2022-02-19 18:17:09 +01:00
|
|
|
}
|
2022-02-21 17:25:08 +01:00
|
|
|
#-----------------------------------------------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Convert HTML: Images
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__make_images() {
|
|
|
|
! [[ "$gsl_header_images" ]] \
|
|
|
|
&& return
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Convert HTML: Files
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__make_files() {
|
|
|
|
! [[ "$gsl_header_files" ]] \
|
|
|
|
&& return
|
|
|
|
|
|
|
|
while read -r "gsl_this_file"
|
|
|
|
do
|
|
|
|
gsl_filename=`
|
|
|
|
awk -F" : " \
|
|
|
|
-v s="$gsl_marker_file$gsl_this_file" \
|
|
|
|
'match($0,s) {print $2}' \
|
|
|
|
"$gsl_post"`
|
|
|
|
|
|
|
|
gsl_filealt=`
|
|
|
|
awk -F" : " \
|
|
|
|
-v s="$gsl_marker_file$gsl_this_file" \
|
|
|
|
'match($0,s) {print $3}' \
|
|
|
|
"$gsl_post"`
|
|
|
|
|
|
|
|
[[ "$gsl_filealt" ]] \
|
|
|
|
&& gsl_HTML_file_title=" title=\"$gsl_filealt\""
|
|
|
|
|
|
|
|
# Set HTML Link
|
|
|
|
case "$gsl_post_type" in
|
|
|
|
post) gsl_HTML_file_url="./files/$gsl_filename" ;;
|
|
|
|
page) gsl_HTML_file_url="../files/$gsl_filename" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Convert file to link
|
|
|
|
gsl_mark_file="$gsl_mo_file$gsl_this_file$gsl_mc_file"
|
|
|
|
gsl_HTML_file_link=`
|
|
|
|
printf '%s%s%s%s%s%s' \
|
|
|
|
"<a href=\"$gsl_HTML_file_url\"" \
|
|
|
|
"$gsl_HTML_file_title" \
|
|
|
|
" target=\"_blank\"" \
|
|
|
|
" class=\"${gsl_site_css}_file-link\">" \
|
|
|
|
"$gsl_this_file" \
|
|
|
|
"</a>"`
|
|
|
|
|
|
|
|
sed -i "s|$gsl_mark_file|$gsl_HTML_file_link|g" \
|
|
|
|
"$gsl_tmp_post"
|
|
|
|
|
|
|
|
done < <(gsl__get_content_finder \
|
|
|
|
-o "$gsl_mo_file" \
|
|
|
|
-c "$gsl_mc_file" \
|
|
|
|
-f "$gsl_tmp_post")
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Convert Inline-code
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__make_inline_codes() {
|
|
|
|
gsl_HTML_inline_code="<code class=\"${gsl_site_css}_inline-code\">"
|
|
|
|
sed -i "s|$gsl_mo_code|$gsl_HTML_inline_code|g" \
|
|
|
|
"$gsl_tmp_post"
|
|
|
|
sed -i "s|$gsl_mc_code|</code>|g" \
|
|
|
|
"$gsl_tmp_post"
|
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Reading Code ; making readability
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__make_a11y() {
|
|
|
|
echo -ne "\r\033[2K: Reading HTML Code for readability..."
|
|
|
|
|
|
|
|
gsl__make_a11y_add_space() {
|
|
|
|
gsl_set_space=$(( gsl_set_space * 2 ))
|
|
|
|
gsl_space=`printf "%${gsl_set_space}s" ""`
|
|
|
|
awk -v b="$gsl_start_line" \
|
|
|
|
-v c="$gsl_stop_line" \
|
|
|
|
-v space="$gsl_space" \
|
|
|
|
'NR > b && NR < c {print space $0}' \
|
|
|
|
"$gsl_tmp_post" \
|
|
|
|
>> "$gsl_a11y_post"
|
|
|
|
}
|
|
|
|
|
|
|
|
gsl_last_title_line=`
|
|
|
|
grep -n "<h" "$gsl_tmp_post" | tail -1 | awk -F: '{print $1}'`
|
|
|
|
|
|
|
|
while read -r "gsl_line_nbr" "gsl_line"
|
|
|
|
do
|
|
|
|
|
|
|
|
if (( $gsl_line_nbr > $gsl_last_title_line ));then
|
|
|
|
gsl_stop_line=`cat "$gsl_tmp_post" | wc -l`
|
|
|
|
gsl__make_a11y_add_space
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$gsl_line" in
|
|
|
|
"<h"*)
|
|
|
|
if [[ $gsl_start_line ]];then
|
|
|
|
gsl_stop_line=$gsl_line_nbr
|
|
|
|
gsl__make_a11y_add_space
|
|
|
|
unset gsl_start_line
|
|
|
|
fi
|
|
|
|
gsl_set_space=`expr substr "$gsl_line" 3 1`
|
|
|
|
gsl_start_line=$gsl_line_nbr
|
|
|
|
unset gsl_stop_line
|
|
|
|
printf '%s\n' "$gsl_line" >> "$gsl_a11y_post"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < <(cat -n "$gsl_tmp_post")
|
|
|
|
}
|