Fixes Italics + Image Converter

This commit is contained in:
Cyrille L 2022-03-02 14:27:50 +01:00
parent f9bdad2da2
commit 6e9acd406d
7 changed files with 61 additions and 39 deletions

View File

@ -90,8 +90,8 @@ gsl_log_c_file="Content File"
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
gsl_mo_p='(' gsl_mo_p='('
gsl_mc_p=')' gsl_mc_p=')'
gsl_mark_image='_image_' gsl_mark_image='_image'
gsl_mark_code='_code_' gsl_mark_code='_code'
gsl_mark_title='#' gsl_mark_title='#'
gsl_mark_bold='\*' gsl_mark_bold='\*'
gsl_mark_strong='\*\*' gsl_mark_strong='\*\*'

View File

@ -180,10 +180,11 @@ _My Great Link+ # Open in new tab
__My Great file __My Great file
# Register in Header. image: 1 : FILENAME : ALT-TEXT # Register in Header. image: 1 : FILENAME : ALT-TEXT
__image:1 _image:1:[OPT l|r|c (left, right, center, alignment)]
_image:1:r
# Block-Code File: Register in Header. code: 1 : FILENAME : Alt Text # Block-Code File: Register in Header. code: 1 : FILENAME : Alt Text
__code:1 _code:1
# Write in STRONG # Write in STRONG
**this strong content** **this strong content**

View File

@ -65,10 +65,11 @@ _My Great Link+ # Open in new tab
__My Great file __My Great file
# Register in Header. image: 1 : FILENAME : ALT-TEXT # Register in Header. image: 1 : FILENAME : ALT-TEXT
__image:1 _image:1:[OPT l|r|c (left, right, center, alignment)]
_image:1:r
# Block-Code File: Register in Header. code: 1 : FILENAME : Alt Text # Block-Code File: Register in Header. code: 1 : FILENAME : Alt Text
__code:1 _code:1
# Write in STRONG # Write in STRONG
**this strong content** **this strong content**

View File

@ -21,8 +21,6 @@ gsl_header_tags=`gsl__get_header "$gsl_marker_tags" "$gsl_post"`
# Check | Make in Loop from header datas $1: process $2:marker $3:file # Check | Make in Loop from header datas $1: process $2:marker $3:file
#====================================================================== #======================================================================
gsl__do_header() { gsl__do_header() {
unset ${!gsl_post_hf@}
while read -r "gsl_header_content_line" while read -r "gsl_header_content_line"
do do
gsl__get_header_fields "$2" gsl__get_header_fields "$2"
@ -40,8 +38,9 @@ do
make) make)
case "$2" in case "$2" in
"$gsl_marker_link") gsl__make_link ;; "$gsl_marker_link") gsl__make_link ;;
"$gsl_marker_abbr") gsl__make_abbr ;; "$gsl_marker_abbr") gsl__make_abbr ;;
"$gsl_marker_image") gsl__make_image ;;
esac esac
;; ;;
esac esac
@ -118,19 +117,18 @@ esac
# Do Italics + Get STATS | $1: Process $2:File # Do Italics + Get STATS | $1: Process $2:File
#====================================================================== #======================================================================
gsl__do_italics() { gsl__do_italics() {
case "$1" in
"stats")
gsl_stat_italics=0
;;
"make")
echo -ne "\r\033[2K: Convrting Italics..."
;;
esac
echo -ne "\r\033[2K: Counting Italics..." echo -ne "\r\033[2K: Counting Italics..."
while read -r "italic" while IFS=: read -r "n" "italic"
do do
[[ `awk -v l="$n" 'NR == l && $1 ~ "_link"' "$2"` ]] && continue
case "$1" in
"make")
echo -ne "\r\033[2K: Convrting Italics..."
;;
esac
if [[ "$italic" ]] && \ if [[ "$italic" ]] && \
[[ `grep "$gsl_mark_italic$italic$gsl_mark_italic" "$2"` ]];then [[ `grep "$gsl_mark_italic$italic$gsl_mark_italic" "$2"` ]];then
@ -147,7 +145,7 @@ do
esac esac
fi fi
done < <(grep -oP "(?<=$gsl_mark_italic).*?(?=$gsl_mark_italic)" "$2") done < <(grep -oPn "(?<=$gsl_mark_italic).*?(?=$gsl_mark_italic)" "$2")
} }
#====================================================================== #======================================================================

View File

@ -14,7 +14,7 @@
# MAIN # MAIN
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
gsl__page_creator() { gsl__page_creator() {
gsl__page_prepare_datas #gsl__page_prepare_datas
gsl__check_templates gsl__check_templates
gsl__html_meta_head gsl__html_meta_head
gsl__page_create gsl__page_create
@ -25,7 +25,7 @@ cat -n "$gsl_srv_wip_page"
# Get Datas for Post/Page # Get Datas for Post/Page
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
gsl__page_prepare_datas() { gsl__page_prepare_datas() {
echo "$gsl_this_conf_domain" echo "D> $gsl_this_conf_domain"
# Check for Files & Folders in server # Check for Files & Folders in server
gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip" gsl_srv_wip="$gsl_site_server/$gsl_site_ndd/wip"

View File

@ -16,6 +16,7 @@ unset gsl_check_done
gsl_db_tmp=`mktemp` gsl_db_tmp=`mktemp`
gsl_stat_link=0 gsl_stat_link=0
gsl_stat_abbr=0 gsl_stat_abbr=0
gsl_stat_italics=0
gsl_stat_file=0 gsl_stat_file=0
gsl_stat_image=0 gsl_stat_image=0
gsl_stat_icode=0 gsl_stat_icode=0

View File

@ -14,18 +14,20 @@
# From: gsl__loop_posts | Convert Post from modules to HTML # From: gsl__loop_posts | Convert Post from modules to HTML
#======================================================================= #=======================================================================
gsl__all_makers() { gsl__all_makers() {
clear
unset gsl_check_done unset gsl_check_done
gsl__prepare_makers gsl__prepare_makers
gsl__do_italics make "$gsl_tmp_post" gsl__page_prepare_datas
gsl__do_header make "$gsl_marker_link" "$gsl_tmp_post"
gsl__do_header make "$gsl_marker_abbr" "$gsl_tmp_post" 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"
gsl__make_titles gsl__make_titles
gsl_ct=0 && gsl__make_titles_div_open gsl_ct=0 && gsl__make_titles_div_open
gsl_ct=0 && gsl__make_titles_div_close gsl_ct=0 && gsl__make_titles_div_close
gsl__do_strongs_bolds make "$gsl_tmp_post" gsl__do_header "make" "$gsl_marker_image" "$gsl_post"
gsl__do_strongs_bolds "make" "$gsl_tmp_post"
gsl__make_paragraphs gsl__make_paragraphs
gsl__do_icode make "$gsl_tmp_post" gsl__do_icode "make" "$gsl_tmp_post"
#echo -ne "\r\033[2K: Searching and converting Block-Codes..." #echo -ne "\r\033[2K: Searching and converting Block-Codes..."
#gsl__check_bcodes #gsl__check_bcodes
@ -33,9 +35,7 @@ gsl__do_icode make "$gsl_tmp_post"
gsl__check_cites gsl__check_cites
gsl__make_a11y gsl__make_a11y
echo -ne "\r\033[2K" echo -ne "\r\033[2K"
rm -f "$gsl_tmp_post" # No more Needed tmp file post
# No more Needed tmp file post
rm -f "$gsl_tmp_post"
# Create HTML Page using gsl_a11y_post # Create HTML Page using gsl_a11y_post
# cat "$gsl_a11y_post" # cat "$gsl_a11y_post"
@ -80,7 +80,7 @@ source "$gsl_this_conf_domain/$gsl_find_domain.conf"
gsl__get_needed_headers gsl__get_needed_headers
# Get extra Headers DATAS # Get extra Headers DATAS
gsl_header_images=`gsl__get_header "$gsl_marker_image" "$gsl_post"` #gsl_header_images=`gsl__get_header "$gsl_marker_image" "$gsl_post"`
gsl__post_content_only gsl__post_content_only
# Code readability a11y # Code readability a11y
@ -300,7 +300,7 @@ 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_o3="<p class=\"${gsl_site_css}_paragraph-3\">"
gsl_html_par_c="</p>" gsl_html_par_c="</p>"
echo -ne "\r\033[2K: Searching and converting Paragraphs..." echo -ne "\r\033[2K: Converting Paragraphs..."
while read -r "gsl_content_line_nbr" "gsl_content_line" while read -r "gsl_content_line_nbr" "gsl_content_line"
do do
@ -490,9 +490,30 @@ EOCITE
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# Convert HTML: Images # Convert HTML: Images
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
gsl__make_images() { gsl__make_image() {
! [[ "$gsl_header_images" ]] \ echo
&& return gsl_this_mark="$gsl_mark_image:$gsl_post_hf_1"
while IFS=: read -r "line_nbr" "this_image"
do
align_image=`awk -F: '{print $3}' <<< "$this_image"`
echo -ne "\r\033[2K: Converting Image... Line:$line_nbr $this_image"
gsl_html_src="src=\"$gsl_uri/images/$gsl_post_hf_2\""
gsl_html_alt="alt=\"$gsl_post_hf_3\""
case "$align_image" in
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\""
;;
esac
gsl_html_image="<img $gsl_html_src $gsl_html_class $gsl_html_alt />"
gsl_post_image="$gsl_mark_image:$gsl_post_hf_1:$align_image"
sed -i "${line_nbr}s|$gsl_post_image|$gsl_html_image|" "$gsl_tmp_post"
done < <(grep -n "$gsl_this_mark" "$gsl_tmp_post")
} }
#----------------------------------------------------------------------- #-----------------------------------------------------------------------