Added Block-Code Converter from file ; marker _code:X
This commit is contained in:
parent
5bb8298d67
commit
df5ad8cf4e
|
@ -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='\*\*'
|
||||
|
|
|
@ -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 "<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"
|
||||
|
||||
done < <(grep -n "$gsl_mark_fcode" "$gsl_tmp_post")
|
||||
}
|
||||
|
||||
|
||||
#======================================================================
|
||||
# From gsl__do_header: Make Link
|
||||
#======================================================================
|
||||
|
@ -131,67 +168,6 @@ 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"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#=======================================================================
|
||||
# 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`
|
||||
"$gsl_mark_blockquote" \
|
||||
"$gsl_tmp_post"`)
|
||||
gsl_lines_nbr=(${gsl_lines_nbr[0]} ${gsl_lines_nbr[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_lines_nbr" ]] \
|
||||
&& return
|
||||
|
||||
# Set gsl_post_header_field_1 gsl_post_header_field_2
|
||||
gsl__get_header_fields "$gsl_marker_code"
|
||||
|
||||
# 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")
|
||||
|
||||
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"
|
||||
|
||||
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
|
||||
#=======================================================================
|
||||
|
|
Loading…
Reference in New Issue