diff --git a/etc/gsl/gsl.conf b/etc/gsl/gsl.conf index 8c3eb9b..f6f834a 100644 --- a/etc/gsl/gsl.conf +++ b/etc/gsl/gsl.conf @@ -91,7 +91,7 @@ gsl_log_c_file="Content File" gsl_mo_p='(' gsl_mc_p=')' gsl_mark_image='_image' -gsl_mark_code='_code' +gsl_mark_fcode='_code' gsl_mark_title='#' gsl_mark_bold='\*' gsl_mark_strong='\*\*' diff --git a/var/lib/gsl/scripts/gsl__post_makers b/var/lib/gsl/scripts/gsl__post_makers index a2e2ec8..9362195 100644 --- a/var/lib/gsl/scripts/gsl__post_makers +++ b/var/lib/gsl/scripts/gsl__post_makers @@ -36,10 +36,7 @@ gsl_ct=0 && gsl__make_titles_div_open gsl_ct=0 && gsl__make_titles_div_close gsl__do_header "make" "$gsl_marker_image" "$gsl_post" gsl__make_paragraphs - -#echo -ne "\r\033[2K: Searching and converting Block-Codes..." -#gsl__check_bcodes - +gsl__make_fcode gsl__check_cites gsl__make_a11y echo -ne "\r\033[2K" @@ -91,6 +88,46 @@ gsl__post_content_only # Converters # --------------------------------- #======================================================================= +#====================================================================== +# 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 "$gsl_bcode_line" >> "$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' \ + "
" \
+         "$(cat "$gsl_file_bcode")" \
+         "
" \ + > "$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" + +done < <(grep -n "$gsl_mark_fcode" "$gsl_tmp_post") +} + + #====================================================================== # From gsl__do_header: Make Link #====================================================================== @@ -131,67 +168,6 @@ gsl_html_long="$gsl_post_hf_1" sed -i "s|$gsl_post_hf_1|$gsl_html_long|" "$gsl_tmp_post" } - - - - - - -#======================================================================= -# Find BLOCK-CODES -#======================================================================= -gsl__check_bcodes() { -gsl_lines_nbr=(` -gsl__get_mark_content_line \ - "$gsl_mark_code" \ - "$gsl_tmp_post"`) - -! [[ "$gsl_lines_nbr" ]] \ - && return - -for i in `seq 1 ${#gsl_lines_nbr[@]}` -do - gsl__make_bcode -done -} - -#======================================================================= -# Find BLOCKQUOTES -#======================================================================= -gsl__check_cites() { -echo -ne "\r\033[2K: Searching and converting Citations..." - -unset gsl_lines_nbr - -gsl_lines_nbr=(` -gsl__get_mark_content_line \ -"$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 -} - -#======================================================================= -# ----------------------------------------------- -# Convert To HTML in duplicated CONTENT Post File -# ----------------------------------------------- -#======================================================================= - #======================================================================= # Find and convert Titles #1-6 #======================================================================= @@ -321,47 +297,38 @@ do done < <(cat -n "$gsl_tmp_post") } +#----------------------------------------------------------------------- #======================================================================= -# Replace gsl_mark_code +# Find BLOCKQUOTES #======================================================================= -gsl__make_bcode() { -# Get mark line nbr -gsl_line_nbr=` +gsl__check_cites() { +echo -ne "\r\033[2K: Searching and converting Citations..." + +unset gsl_lines_nbr + +gsl_lines_nbr=(` gsl__get_mark_content_line \ - "$gsl_mark_code" \ - "$gsl_tmp_post" | head -1` - -#--------- -# 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` +"$gsl_mark_blockquote" \ +"$gsl_tmp_post"`) +gsl_lines_nbr=(${gsl_lines_nbr[0]} ${gsl_lines_nbr[1]}) -# Set gsl_post_header_field_1 gsl_post_header_field_2 -gsl__get_header_fields "$gsl_marker_code" +! [[ "$gsl_lines_nbr" ]] \ + && return -# 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 "$gsl_bcode_line" >> "$gsl_file_bcode" -done < <(cat "$gsl_dir_domain_files/$gsl_post_header_field_2") - -printf '%s %s\n%b\n%s\n' \ - "
" \
-       "$(cat "$gsl_file_bcode")" \
-       "
" \ - > "$gsl_file_tmp_code" - -sed -i "${gsl_line_nbr}r $gsl_file_tmp_code" "$gsl_tmp_post" -sed -i "${gsl_line_nbr}d" "$gsl_tmp_post" -rm -f "$gsl_file_tmp_code" -rm -f "$gsl_file_bcode" + 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 } -#----------------------------------------------------------------------- #======================================================================= # Replace and Convert this blockquote #=======================================================================