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-03-05 18:06:48 +01:00
|
|
|
# Code readability a11y
|
|
|
|
gsl_a11y_post=`mktemp`
|
|
|
|
|
2022-04-14 11:00:07 +02:00
|
|
|
# Get content only, not header in a file
|
2022-03-06 01:47:58 +01:00
|
|
|
gsl__post_content_only
|
2022-03-02 14:27:50 +01:00
|
|
|
|
2022-04-14 11:00:07 +02:00
|
|
|
# Get base uri from post/page type:
|
|
|
|
case "$gsl_post_type" in
|
|
|
|
post) gsl_uri=".." ;;
|
|
|
|
page) gsl_uri="." ;;
|
|
|
|
esac
|
|
|
|
|
2022-03-02 14:27:50 +01:00
|
|
|
gsl__do_italics "make" "$gsl_tmp_post" # First
|
|
|
|
gsl__do_header "make" "$gsl_marker_link" "$gsl_post"
|
|
|
|
gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post"
|
2022-04-13 12:24:39 +02:00
|
|
|
gsl__make_newline
|
2022-04-07 14:58:26 +02:00
|
|
|
gsl__make_files
|
2022-03-04 14:50:56 +01:00
|
|
|
gsl__do_strongs_bolds "make" "$gsl_tmp_post"
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl__make_list
|
2022-04-16 12:08:29 +02:00
|
|
|
|
2022-03-04 14:50:56 +01:00
|
|
|
gsl__do_icode "make" "$gsl_tmp_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl__make_titles
|
2022-03-02 14:27:50 +01:00
|
|
|
gsl__do_header "make" "$gsl_marker_image" "$gsl_post"
|
2022-02-21 17:25:08 +01:00
|
|
|
gsl__make_paragraphs
|
2022-03-05 20:15:53 +01:00
|
|
|
|
|
|
|
# From File_Code
|
|
|
|
gsl_fcode_nbr=`grep "$gsl_mark_fcode" "$gsl_tmp_post" | wc -l`
|
2022-04-16 12:08:29 +02:00
|
|
|
if (( $gsl_fcode_nbr > 0 ));then
|
|
|
|
for fcode in `seq 1 $gsl_fcode_nbr`
|
|
|
|
do
|
|
|
|
gsl__make_fcode
|
|
|
|
done
|
|
|
|
fi
|
2022-03-05 20:15:53 +01:00
|
|
|
|
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"
|
2022-03-05 18:18:46 +01:00
|
|
|
|
2022-03-02 14:27:50 +01:00
|
|
|
rm -f "$gsl_tmp_post" # No more Needed tmp file post
|
2022-02-27 19:16:16 +01:00
|
|
|
|
2022-03-10 14:47:00 +01:00
|
|
|
# Create SRV folder according to post type
|
|
|
|
[[ "$gsl_post_type" == "post" ]] \
|
2022-03-27 18:46:48 +02:00
|
|
|
&& mkdir -p "$gsl_srv_wip/$gsl_header_slug/" \
|
|
|
|
&& gsl__logs_print \
|
|
|
|
"$gsl_log_w" \
|
|
|
|
"SRV" \
|
|
|
|
"wip" \
|
|
|
|
"Create folder: $gsl_header_slug" \
|
|
|
|
"$gsl_srv_wip/$gsl_header_slug/" \
|
|
|
|
&& gsl_checker_war=true
|
2022-03-10 14:47:00 +01:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# Create HTML Page using gsl_a11y_post
|
|
|
|
gsl__page_creator
|
2022-03-27 18:46:48 +02:00
|
|
|
gsl__db_set_post_status wip
|
2022-02-19 18:17:09 +01:00
|
|
|
|
2022-03-05 18:18:46 +01:00
|
|
|
rm -f "$gsl_a11y_post" # No more Needed 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
|
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# ---------------------------------
|
2022-02-27 19:16:16 +01:00
|
|
|
# Converters
|
2022-02-19 18:17:09 +01:00
|
|
|
# ---------------------------------
|
|
|
|
#=======================================================================
|
2022-03-08 17:53:40 +01:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
#======================================================================
|
|
|
|
# Convert List.Get first/last line item / repeat till no more mark
|
|
|
|
#======================================================================
|
2022-04-23 17:51:46 +02:00
|
|
|
# Loop till no more list marker
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl__make_list() {
|
2022-04-25 13:17:09 +02:00
|
|
|
if [[ `awk -v mls="\$gsl_mark_listo" \
|
|
|
|
'match($1,mls) {print NR,$0;exit}' \
|
2022-04-23 17:51:46 +02:00
|
|
|
"$gsl_tmp_post"` ]] || \
|
2022-04-25 13:17:09 +02:00
|
|
|
[[ `awk -v mls="\$gsl_mark_list" \
|
|
|
|
'match($1,mls) {print NR,$0;exit}' \
|
2022-04-14 14:14:42 +02:00
|
|
|
"$gsl_tmp_post"` ]];then
|
2022-04-23 17:51:46 +02:00
|
|
|
gsl__make_list_read_by_block
|
2022-04-14 14:14:42 +02:00
|
|
|
fi
|
2022-04-23 17:51:46 +02:00
|
|
|
return
|
2022-04-14 14:14:42 +02:00
|
|
|
}
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# =====================================================================
|
|
|
|
# Read list by block, create tmp file, convert in HTML, replace block
|
|
|
|
# ln: line number | ml: marker list
|
|
|
|
# =====================================================================
|
|
|
|
gsl__make_list_read_by_block() {
|
|
|
|
unset list_lb list_le
|
|
|
|
|
|
|
|
# Making tmp block file list
|
|
|
|
gsl_file_block_list=`mktemp`
|
|
|
|
while read -r "ln" "ml" "content"
|
2022-03-08 17:53:40 +01:00
|
|
|
do
|
2022-04-23 17:51:46 +02:00
|
|
|
case "$ml" in
|
2022-04-14 14:14:42 +02:00
|
|
|
"$gsl_mark_list"*|"$gsl_mark_listo"*)
|
2022-04-23 17:51:46 +02:00
|
|
|
case "$ml" in
|
|
|
|
"$gsl_mark_list"*)
|
|
|
|
gsl_html_uol="ul"
|
|
|
|
;;
|
|
|
|
"$gsl_mark_listo"*)
|
|
|
|
gsl_html_uol="ol"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
! [[ $list_lb ]] && list_lb="$ln"
|
|
|
|
echo "$ml $content" >> "$gsl_file_block_list"
|
2022-03-08 17:53:40 +01:00
|
|
|
;;
|
|
|
|
""|*)
|
2022-04-23 17:51:46 +02:00
|
|
|
if [[ $list_lb ]];then
|
|
|
|
list_le=$ln
|
|
|
|
echo "" >> "$gsl_file_block_list"
|
|
|
|
break
|
|
|
|
fi
|
2022-03-08 17:53:40 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < <(cat -n "$gsl_tmp_post")
|
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# Convert block_list
|
|
|
|
echo -ne "\r\033[2K: Converting list block... $list_lb-$list_le"
|
|
|
|
gsl__make_list_convert
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# Remove in gsl_tmp_post block list and replace with $gsl_file_html_list
|
|
|
|
diff_lines=$(( list_le - list_lb ))
|
|
|
|
#seq $list_lb $list_le
|
|
|
|
for rml in `seq 1 $diff_lines`
|
2022-03-08 17:53:40 +01:00
|
|
|
do
|
2022-04-23 17:51:46 +02:00
|
|
|
sed -i "${list_lb}d" "$gsl_tmp_post"
|
|
|
|
done
|
|
|
|
sed -i "$((list_lb -1))r $gsl_file_html_list" "$gsl_tmp_post"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# No more needed html file list
|
|
|
|
rm -f "$gsl_file_html_list"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# No more needed block list file
|
2022-03-08 17:53:40 +01:00
|
|
|
rm -f "$gsl_file_block_list"
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
|
|
# Go again if new list found
|
|
|
|
gsl__make_list
|
2022-03-08 17:53:40 +01:00
|
|
|
}
|
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# =====================================================================
|
|
|
|
# Create TMP HTML block list file
|
|
|
|
# =====================================================================
|
2022-03-08 17:53:40 +01:00
|
|
|
gsl__make_list_convert() {
|
2022-04-25 13:17:09 +02:00
|
|
|
gsl_file_html_list=`mktemp`
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# mln: marker list number | pmln: previous list mark number
|
|
|
|
gsl__make_list_count_prev_mark() {
|
2022-04-25 13:17:09 +02:00
|
|
|
pml=`gawk -v pln=$(( ln -1 )) 'NR == pln {print $1}' "$gsl_file_block_list"`
|
2022-04-23 17:51:46 +02:00
|
|
|
pmln=${#pml}
|
|
|
|
}
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
mln_indent=0
|
|
|
|
while read -r "ln" "ml" "content"
|
2022-03-08 17:53:40 +01:00
|
|
|
do
|
2022-04-23 17:51:46 +02:00
|
|
|
mln=${#ml}
|
|
|
|
(( $mln_indent < $mln )) \
|
|
|
|
&& mln_indent=$mln \
|
|
|
|
&& mln_indent_close=$((mln_indent * 3 - 3))
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
gsl__make_list_count_prev_mark
|
|
|
|
diff_pmln_mln=$(( mln - pmln ))
|
|
|
|
|
|
|
|
#echo "$mln (pmln=$pmln ; diff: $diff_pmln_mln)" >> "$gsl_file_html_list"
|
|
|
|
if (( $diff_pmln_mln == 0 ));then
|
|
|
|
|
|
|
|
printf "%$((mln * 3))s%s\n" \
|
2022-03-08 17:53:40 +01:00
|
|
|
"" \
|
2022-04-23 17:51:46 +02:00
|
|
|
"<li class=\"${gsl_site_css}_list-li ${gsl_site_css}_list-$mln\">$content</li>" \
|
|
|
|
>> "$gsl_file_html_list"
|
|
|
|
|
|
|
|
elif (( $diff_pmln_mln > 0 ));then
|
|
|
|
|
|
|
|
printf "%$((mln * 3 - 3))s%s\n%$((mln * 3))s%s\n" \
|
2022-03-08 17:53:40 +01:00
|
|
|
"" \
|
2022-04-14 14:14:42 +02:00
|
|
|
"<$gsl_html_uol class=\"${gsl_site_css}_list-$gsl_html_uol\">" \
|
2022-03-08 17:53:40 +01:00
|
|
|
"" \
|
2022-04-23 17:51:46 +02:00
|
|
|
"<li class=\"${gsl_site_css}_list-li ${gsl_site_css}_list-$mln\">$content</li>" \
|
|
|
|
>> "$gsl_file_html_list"
|
|
|
|
|
|
|
|
elif (( $diff_pmln_mln < 0 ));then
|
|
|
|
|
|
|
|
for i in `seq $diff_pmln_mln -1`
|
|
|
|
do
|
|
|
|
if [[ "$content" ]];then
|
|
|
|
|
|
|
|
printf "%${mln_indent_close}s%s\n%${mln_indent_close}s%s\n" \
|
|
|
|
"" \
|
|
|
|
"</$gsl_html_uol>" \
|
|
|
|
"" \
|
|
|
|
"<li class=\"${gsl_site_css}_list-li ${gsl_site_css}_list-$mln\">$content</li>" \
|
|
|
|
>> "$gsl_file_html_list"
|
2022-04-25 13:17:09 +02:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
else
|
|
|
|
|
|
|
|
printf "%${mln_indent_close}s%s\n" \
|
|
|
|
"" \
|
|
|
|
"</$gsl_html_uol>" \
|
|
|
|
>> "$gsl_file_html_list"
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
fi
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
mln_indent_close=$((mln_indent_close - 3))
|
|
|
|
(( $mln_indent_close < 0 )) && mln_indent_close=0
|
2022-03-08 17:53:40 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
done < <(cat -n "$gsl_file_block_list")
|
2022-03-08 17:53:40 +01:00
|
|
|
}
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
|
2022-03-05 19:25:04 +01:00
|
|
|
#======================================================================
|
|
|
|
# Replace gsl_mark_fcode
|
|
|
|
#======================================================================
|
|
|
|
gsl__make_fcode() {
|
|
|
|
while IFS=: read -r "line" "mark" "nbr"
|
|
|
|
do
|
|
|
|
# Get File
|
|
|
|
gsl_file_fcode=`
|
|
|
|
grep "${gsl_marker_code}$nbr" "$gsl_post" \
|
|
|
|
| awk -F" : " '{print $2}'`
|
|
|
|
|
|
|
|
echo -ne "\r\033[2K: Converting Block-Codes... $gsl_file_fcode"
|
|
|
|
|
|
|
|
gsl_css_class="${gsl_site_css}_block-code"
|
|
|
|
|
|
|
|
# Create tmp file from block-code, adding span for line numbers 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_file_fcode")
|
|
|
|
|
|
|
|
gsl_file_tmp_code=`mktemp`
|
|
|
|
printf '%s %s\n%b\n%s\n' \
|
|
|
|
"<pre class=\"$gsl_css_class" \
|
|
|
|
"${gsl_css_class}-$gsl_post_header_field_1\">" \
|
|
|
|
"$(cat "$gsl_file_bcode")" \
|
|
|
|
"</pre>" \
|
|
|
|
> "$gsl_file_tmp_code"
|
|
|
|
|
|
|
|
# Replace in tmp post and delete mark
|
|
|
|
sed -i "${line}r $gsl_file_tmp_code" "$gsl_tmp_post"
|
|
|
|
sed -i "${line}d" "$gsl_tmp_post"
|
|
|
|
rm -f "$gsl_file_tmp_code"
|
|
|
|
rm -f "$gsl_file_bcode"
|
2022-03-05 20:15:53 +01:00
|
|
|
done < <(grep -n "$gsl_mark_fcode" "$gsl_tmp_post" | head -n 1)
|
2022-03-05 19:25:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
#======================================================================
|
|
|
|
# From gsl__do_header: Make Link
|
|
|
|
#======================================================================
|
|
|
|
gsl__make_link() {
|
|
|
|
gsl_post_hf_1="${gsl_post_hf_1}"
|
|
|
|
gsl_post_hf_1_t="${gsl_post_hf_1}+"
|
|
|
|
|
2022-04-13 18:33:11 +02:00
|
|
|
[[ "$gsl_post_hf_3" ]] \
|
|
|
|
&& gsl_html_link_title=" title=\"$gsl_post_hf_3\""
|
2022-04-07 17:12:50 +02:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# target blank
|
|
|
|
gsl_html_link_t=`
|
|
|
|
printf '%s%s%s%s' \
|
|
|
|
"<a href=\"$gsl_post_hf_2\"$gsl_html_link_title " \
|
2022-04-07 17:52:35 +02:00
|
|
|
"target=\"blank\">" \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_post_hf_1" \
|
|
|
|
"</a>"`
|
2022-04-13 18:33:11 +02:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
echo -ne "\r\033[2K: Converting Link... $gsl_post_hf_1"
|
2022-02-27 19:16:16 +01:00
|
|
|
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>"`
|
2022-04-13 18:33:11 +02:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
sed -i "s|_${gsl_post_hf_1}|$gsl_html_link|g" "$gsl_tmp_post"
|
2022-04-13 18:33:11 +02:00
|
|
|
unset gsl_post_hf_3 gsl_html_link_title
|
2022-02-27 19:16:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#======================================================================
|
|
|
|
# From gsl__do_header: Make ABBRS
|
|
|
|
#======================================================================
|
|
|
|
gsl__make_abbr() {
|
2022-04-23 17:51:46 +02:00
|
|
|
echo -ne "\r\033[2K: Converting ABBR... $gsl_post_hf_1"
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
#=======================================================================
|
2022-04-23 17:51:46 +02:00
|
|
|
# Find and convert Titles #1-6 + block dib
|
2022-02-21 17:25:08 +01:00
|
|
|
#=======================================================================
|
|
|
|
gsl__make_titles() {
|
2022-04-23 17:51:46 +02:00
|
|
|
gsl_file_block_titles=`mktemp`
|
2022-02-27 19:16:16 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
while read -r "ln" "t" "content"
|
|
|
|
do
|
|
|
|
echo -ne "\r\033[2K: Converting Block Title... $t $content"
|
|
|
|
if [[ $ln_o ]];then
|
|
|
|
if [[ $ln_c ]];then
|
|
|
|
ln_o=$ln_c
|
|
|
|
ln_c=$ln
|
|
|
|
else
|
|
|
|
ln_c=$ln
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
ln_o=$ln
|
|
|
|
tn=${t: -1}
|
|
|
|
echo "<h$tn>$content</h$tn>" >> "$gsl_file_block_titles"
|
|
|
|
fi
|
2022-02-21 17:25:08 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
if [[ $ln_c ]];then
|
|
|
|
tn=${t: -1}
|
|
|
|
if [[ `awk -v o="$ln_o" -v c="$ln_c" \
|
|
|
|
'NR > o && NR < c' \
|
|
|
|
"$gsl_tmp_post"` ]];then
|
|
|
|
echo "<div class=\"${gsl_site_css}_content-p ${gsl_site_css}_content-p$tn\">" \
|
|
|
|
>> "$gsl_file_block_titles"
|
|
|
|
awk -v o="$ln_o" -v c="$ln_c" \
|
|
|
|
'NR > o && NR < c && $0' \
|
|
|
|
"$gsl_tmp_post" \
|
|
|
|
>> "$gsl_file_block_titles"
|
|
|
|
echo -e "</div>\n" \
|
|
|
|
>> "$gsl_file_block_titles"
|
|
|
|
fi
|
|
|
|
echo "<h$tn>$content</h$tn>" >> "$gsl_file_block_titles"
|
|
|
|
fi
|
2022-04-07 18:47:48 +02:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
done < <(awk '$1 ~ /#/ {print NR,$0}' "$gsl_tmp_post")
|
2022-02-21 17:25:08 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
# Doing the last title block content
|
|
|
|
last_line=`cat "$gsl_tmp_post" | wc -l`
|
|
|
|
if [[ `awk -v o="$ln_o" -v c="$last_line" \
|
|
|
|
'NR > o && NR <= c' \
|
|
|
|
"$gsl_tmp_post"` ]];then
|
|
|
|
echo "<div class=\"${gsl_site_css}_content-p ${gsl_site_css}_content-p$tn\">" \
|
|
|
|
>> "$gsl_file_block_titles"
|
|
|
|
awk -v o="$ln_c" -v c="$last_line" \
|
|
|
|
'NR > o && NR <= c' \
|
|
|
|
"$gsl_tmp_post" \
|
|
|
|
>> "$gsl_file_block_titles"
|
|
|
|
echo "</div>" >> "$gsl_file_block_titles"
|
|
|
|
fi
|
2022-02-21 17:25:08 +01:00
|
|
|
|
2022-04-23 17:51:46 +02:00
|
|
|
cat "$gsl_file_block_titles" > "$gsl_tmp_post"
|
|
|
|
rm -f "$gsl_file_block_titles"
|
2022-02-21 17:25:08 +01:00
|
|
|
}
|
2022-04-23 17:51:46 +02:00
|
|
|
|
2022-02-21 17:25:08 +01:00
|
|
|
|
|
|
|
#=======================================================================
|
|
|
|
# Find and convert paragraphs (3 different css styles)
|
|
|
|
#=======================================================================
|
|
|
|
gsl__make_paragraphs() {
|
2022-03-02 14:27:50 +01:00
|
|
|
echo -ne "\r\033[2K: Converting Paragraphs..."
|
2022-03-01 12:39:16 +01:00
|
|
|
|
2022-04-25 13:17:09 +02:00
|
|
|
while read -r "ln" "content"
|
2022-02-21 17:25:08 +01:00
|
|
|
do
|
2022-04-25 13:17:09 +02:00
|
|
|
case "$content" in
|
2022-03-02 17:25:23 +01:00
|
|
|
")")
|
2022-04-25 13:17:09 +02:00
|
|
|
sed -i "${ln}s,.*,</p>," \
|
2022-03-02 17:25:23 +01:00
|
|
|
"$gsl_tmp_post"
|
|
|
|
;;
|
2022-04-25 13:17:09 +02:00
|
|
|
|
|
|
|
"("*)
|
|
|
|
gsl_css_id=`
|
|
|
|
awk -v l="$ln" \
|
|
|
|
'NR == l {print $2}' \
|
|
|
|
"$gsl_tmp_post"`
|
|
|
|
|
|
|
|
if [[ "$gsl_css_id" ]] && \
|
|
|
|
[[ `grep '^[-0-9a-zA-Z]*$' <<<"$gsl_css_id"` ]];then
|
|
|
|
gsl_css_id="-$gsl_css_id"
|
|
|
|
fi
|
|
|
|
gsl_html_par_id="<p class=\"${gsl_site_css}_paragraph$gsl_css_id\">"
|
|
|
|
|
|
|
|
sed -i "${ln}s,.*,$gsl_html_par_id," \
|
2022-03-02 17:25:23 +01:00
|
|
|
"$gsl_tmp_post"
|
|
|
|
;;
|
2022-04-25 13:17:09 +02:00
|
|
|
|
2022-03-02 17:25:23 +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-03-05 19:25:04 +01:00
|
|
|
#-----------------------------------------------------------------------
|
2022-02-19 18:17:09 +01:00
|
|
|
#=======================================================================
|
2022-03-05 19:25:04 +01:00
|
|
|
# Find BLOCKQUOTES
|
2022-02-19 18:17:09 +01:00
|
|
|
#=======================================================================
|
2022-03-05 19:25:04 +01:00
|
|
|
gsl__check_cites() {
|
|
|
|
echo -ne "\r\033[2K: Searching and converting Citations..."
|
|
|
|
|
|
|
|
unset gsl_lines_nbr
|
|
|
|
|
|
|
|
gsl_lines_nbr=(`
|
2022-02-19 18:17:09 +01:00
|
|
|
gsl__get_mark_content_line \
|
2022-03-05 19:25:04 +01:00
|
|
|
"$gsl_mark_blockquote" \
|
|
|
|
"$gsl_tmp_post"`)
|
|
|
|
gsl_lines_nbr=(${gsl_lines_nbr[0]} ${gsl_lines_nbr[1]})
|
|
|
|
|
|
|
|
! [[ "$gsl_lines_nbr" ]] \
|
|
|
|
&& return
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#=======================================================================
|
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
|
|
|
|
#-----------------------------------------------------------------------
|
2022-03-02 14:27:50 +01:00
|
|
|
gsl__make_image() {
|
|
|
|
gsl_this_mark="$gsl_mark_image:$gsl_post_hf_1"
|
2022-04-07 17:12:50 +02:00
|
|
|
|
2022-04-14 11:00:07 +02:00
|
|
|
while IFS=: read -r "line_nbr" \
|
|
|
|
"marker" \
|
|
|
|
"this_image" \
|
|
|
|
"align_image" \
|
|
|
|
"width" \
|
|
|
|
"height" \
|
|
|
|
"target"
|
2022-03-02 14:27:50 +01:00
|
|
|
do
|
2022-04-11 18:06:38 +02:00
|
|
|
|
2022-04-14 11:00:07 +02:00
|
|
|
# Get this marker
|
|
|
|
gsl_this_mark=`awk -v ln="$line_nbr" 'NR == ln' $gsl_tmp_post`
|
|
|
|
|
|
|
|
#align_image=`awk -F: '{print $3}' <<< "$this_image"`
|
2022-03-02 14:27:50 +01:00
|
|
|
case "$align_image" in
|
2022-04-14 11:00:07 +02:00
|
|
|
R|r|D|d) gsl_html_class="class=\"${gsl_site_css}_image_right\"" ;;
|
|
|
|
L|l|G|g) gsl_html_class="class=\"${gsl_site_css}_image_left\"" ;;
|
|
|
|
C|c) gsl_html_class="class=\"${gsl_site_css}_image_center\"";;
|
|
|
|
*) gsl_html_class="class=\"${gsl_site_css}_image_center\"";;
|
2022-03-02 14:27:50 +01:00
|
|
|
esac
|
2022-04-07 17:12:50 +02:00
|
|
|
|
2022-04-14 11:00:07 +02:00
|
|
|
gsl_html_src="src=\"$gsl_uri/images/$gsl_post_hf_2\""
|
|
|
|
gsl_html_alt="alt=\"$gsl_post_hf_3\" title=\"$gsl_post_hf_3\""
|
2022-04-15 11:49:35 +02:00
|
|
|
[[ "$width" ]] && gsl_html_width=" style=\"width:${width}px;\""
|
|
|
|
[[ "$height" ]] && gsl_html_height=" style=\"height:${height}px;\""
|
2022-04-14 11:00:07 +02:00
|
|
|
|
|
|
|
gsl_html_image=`
|
2022-04-15 11:49:35 +02:00
|
|
|
printf '%s %s %s%s%s' \
|
2022-04-14 11:00:07 +02:00
|
|
|
"<img $gsl_html_src" \
|
|
|
|
"$gsl_html_class" \
|
|
|
|
"$gsl_html_alt" \
|
|
|
|
"$gsl_html_width" \
|
|
|
|
"$gsl_html_height />"`
|
2022-04-11 18:06:38 +02:00
|
|
|
|
2022-04-14 11:00:07 +02:00
|
|
|
[[ "$target" ]] \
|
|
|
|
&& gsl_html_image="<a target=\"_blank\" href=\"$gsl_uri/images/$gsl_post_hf_2\">$gsl_html_image</a>"
|
|
|
|
|
|
|
|
echo -ne "\r\033[2K: Converting Image... Line:$line_nbr $gsl_this_mark"
|
|
|
|
sed -i "${line_nbr}s|$gsl_this_mark|$gsl_html_image|" "$gsl_tmp_post"
|
2022-04-07 17:12:50 +02:00
|
|
|
|
2022-03-02 14:27:50 +01:00
|
|
|
done < <(grep -n "$gsl_this_mark" "$gsl_tmp_post")
|
2022-02-27 19:16:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Convert HTML: Files
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__make_files() {
|
2022-04-07 14:58:26 +02:00
|
|
|
echo
|
2022-04-07 17:12:50 +02:00
|
|
|
|
|
|
|
# Set HTML Base Link
|
|
|
|
case "$gsl_post_type" in
|
|
|
|
post) gsl_bfile_url="../files" ;;
|
|
|
|
page) gsl_bfile_url="files" ;;
|
|
|
|
esac
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
while read -r "gsl_this_file"
|
|
|
|
do
|
2022-04-07 15:04:27 +02:00
|
|
|
gsl_this_file=${gsl_this_file/$gsl_marker_file/}
|
2022-04-07 14:58:26 +02:00
|
|
|
|
|
|
|
gsl_filetxt=`
|
|
|
|
awk -F" : " \
|
|
|
|
'{print $1}' \
|
|
|
|
<<< "$gsl_this_file"`
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl_filename=`
|
|
|
|
awk -F" : " \
|
2022-04-07 14:58:26 +02:00
|
|
|
'{print $2}' \
|
|
|
|
<<< "$gsl_this_file"`
|
2022-02-27 19:16:16 +01:00
|
|
|
|
|
|
|
gsl_filealt=`
|
|
|
|
awk -F" : " \
|
2022-04-07 14:58:26 +02:00
|
|
|
'{print $3}' \
|
|
|
|
<<< "$gsl_this_file"`
|
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
[[ "$gsl_filealt" ]] \
|
|
|
|
&& gsl_HTML_file_title=" title=\"$gsl_filealt\""
|
2022-04-07 17:12:50 +02:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
# Convert file to link
|
2022-04-07 14:58:26 +02:00
|
|
|
gsl_mark_file="$gsl_mark_file$gsl_filetxt"
|
2022-02-27 19:16:16 +01:00
|
|
|
gsl_HTML_file_link=`
|
|
|
|
printf '%s%s%s%s%s%s' \
|
2022-04-07 17:12:50 +02:00
|
|
|
"<a href=\"$gsl_bfile_url/$gsl_filename\"" \
|
2022-02-27 19:16:16 +01:00
|
|
|
"$gsl_HTML_file_title" \
|
|
|
|
" target=\"_blank\"" \
|
|
|
|
" class=\"${gsl_site_css}_file-link\">" \
|
2022-04-07 14:58:26 +02:00
|
|
|
"$gsl_filetxt" \
|
2022-02-27 19:16:16 +01:00
|
|
|
"</a>"`
|
|
|
|
|
2022-04-07 17:12:50 +02:00
|
|
|
echo -ne "\r\033[2K: Converting File... $gsl_mark_file"
|
2022-02-27 19:16:16 +01:00
|
|
|
sed -i "s|$gsl_mark_file|$gsl_HTML_file_link|g" \
|
|
|
|
"$gsl_tmp_post"
|
|
|
|
|
2022-04-07 14:58:26 +02:00
|
|
|
done < <(grep "$gsl_marker_file" "$gsl_post")
|
2022-02-27 19:16:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Convert Inline-code
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__make_inline_codes() {
|
|
|
|
gsl_HTML_inline_code="<code class=\"${gsl_site_css}_inline-code\">"
|
2022-04-11 18:06:38 +02:00
|
|
|
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"
|
2022-02-27 19:16:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# 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
|
2022-04-23 17:51:46 +02:00
|
|
|
|
|
|
|
# print last line and stop
|
|
|
|
awk -v last="$gsl_stop_line" -v space="$gsl_space" \
|
|
|
|
'NR == last {print space $0}' \
|
|
|
|
"$gsl_tmp_post" \
|
|
|
|
>> "$gsl_a11y_post"
|
2022-02-27 19:16:16 +01:00
|
|
|
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
|
2022-04-11 18:06:38 +02:00
|
|
|
|
2022-02-27 19:16:16 +01:00
|
|
|
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")
|
|
|
|
}
|
2022-04-13 12:24:39 +02:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Create a new line from | to <br />
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
gsl__make_newline() {
|
|
|
|
while read -r "nbrline" "nl" "content"
|
|
|
|
do
|
|
|
|
echo -ne "\r\033[2K: Converting New Line... | > <br />"
|
|
|
|
sed -i "${nbrline}s,|,<br />," "$gsl_tmp_post"
|
|
|
|
done < <(awk -v nl="|" '$1==nl {print NR,$0}' "$gsl_tmp_post")
|
|
|
|
echo -ne "\r\033[2K"
|
|
|
|
}
|