Fix Italics, strongs, bolds in inline code

This commit is contained in:
Cyrille L 2022-03-04 14:50:56 +01:00
parent a2c31e41f4
commit e45aee1e25
2 changed files with 52 additions and 56 deletions

View File

@ -58,9 +58,6 @@ case "$1" in
gsl_stat_bolds=0 gsl_stat_bolds=0
;; ;;
"make")
echo -ne "\r\033[2K: Convrting Strongs & Bolds..."
;;
esac esac
while read -r "strong" while read -r "strong"
@ -73,7 +70,13 @@ do
((gsl_stat_strongs++)) ((gsl_stat_strongs++))
;; ;;
"make") "make")
echo -ne "\r\033[2K: Convrting Strong... $strong" # Check if in Inline-Code
[[ `awk -v l="$n" 'NR == l' "$2" \
| grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)"` \
=~ "$strong" ]] \
&& continue
echo -ne "\r\033[2K: Converting Strong... $strong"
gsl_strong="$gsl_mark_strong$strong$gsl_mark_strong" gsl_strong="$gsl_mark_strong$strong$gsl_mark_strong"
gsl_html_strong="<strong>$strong</strong>" gsl_html_strong="<strong>$strong</strong>"
sed -i "s|$gsl_strong|$gsl_html_strong|g" "$2" sed -i "s|$gsl_strong|$gsl_html_strong|g" "$2"
@ -85,8 +88,7 @@ done < <(grep -oP "(?<=$gsl_mark_strong).*?(?=$gsl_mark_strong)" "$2")
# Bolds # Bolds
echo -ne "\r\033[2K: Counting Bolds..." while IFS=: read -r "n" "bold"
while read -r "bold"
do do
if [[ "$bold" ]] && \ if [[ "$bold" ]] && \
[[ `grep "$gsl_mark_bold$bold$gsl_mark_bold" "$2"` ]];then [[ `grep "$gsl_mark_bold$bold$gsl_mark_bold" "$2"` ]];then
@ -94,17 +96,25 @@ do
case "$1" in case "$1" in
"stats") "stats")
((gsl_stat_bolds++)) ((gsl_stat_bolds++))
echo -ne "\r\033[2K: Counting Bolds... $gsl_stat_bolds"
;; ;;
"make") "make")
echo -ne "\r\033[2K: Convrting Bold... $bold"
gsl_bold="$gsl_mark_bold$bold$gsl_mark_bold" gsl_bold="$gsl_mark_bold$bold$gsl_mark_bold"
# Check if in Inline-Code
[[ `awk -v l="$n" 'NR == l' "$2" \
| grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)"` \
=~ "$bold" ]] \
&& continue
echo -ne "\r\033[2K: Converting Bold... Line $n: $bold"
gsl_html_bold="<b>$bold</b>" gsl_html_bold="<b>$bold</b>"
sed -i "s|$gsl_bold|$gsl_html_bold|g" "$2" sed -i "s|$gsl_bold|$gsl_html_bold|g" "$2"
;; ;;
esac esac
fi fi
done < <(grep -oP "(?<=$gsl_mark_bold).*?(?=$gsl_mark_bold)" "$2") done < <(grep -oPn "(?<=$gsl_mark_bold).*?(?=$gsl_mark_bold)" "$2")
case "$1" in case "$1" in
"stats") "stats")
@ -123,12 +133,6 @@ do
[[ `awk -v l="$n" 'NR == l && $1 ~ "_link"' "$2"` ]] && continue [[ `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
@ -137,12 +141,17 @@ do
((gsl_stat_italics++)) ((gsl_stat_italics++))
;; ;;
"make") "make")
echo -ne "\r\033[2K: Convrting Italic... $italic" # Check if in Inline-Code
[[ `awk -v l="$n" 'NR == l' "$2" \
| grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)"` \
=~ "$italic" ]] \
&& continue
echo -ne "\r\033[2K: Converting Italic... $italic"
gsl_italic="$gsl_mark_italic$italic$gsl_mark_italic" gsl_italic="$gsl_mark_italic$italic$gsl_mark_italic"
gsl_html_italic="<em>$italic</em>" gsl_html_italic="<em>$italic</em>"
sed -i "s|$gsl_italic|$gsl_html_italic|g" "$2" sed -i "s|$gsl_italic|$gsl_html_italic|g" "$2"
;; ;;
esac esac
fi fi
done < <(grep -oPn "(?<=$gsl_mark_italic).*?(?=$gsl_mark_italic)" "$2") done < <(grep -oPn "(?<=$gsl_mark_italic).*?(?=$gsl_mark_italic)" "$2")
@ -158,42 +167,35 @@ case "$1" in
;; ;;
"make") "make")
echo
echo "Converting icodes..."
gsl_html_icode_o="<code class=\"${gsl_site_css}-code\">" gsl_html_icode_o="<code class=\"${gsl_site_css}-code\">"
echo -ne "\r\033[2K: Convrting Inline-Codes..." gsl_html_icode_c="</code>"
;;
esac
echo -ne "\r\033[2K: Counting Inline-Codes..." while IFS=: read -r "n" "line"
while read -r "icode" do
do unset gsl_icode_open
if [[ "$icode" ]] && \ for i in $(seq 1 ${#line})
[[ `grep "$gsl_mark_code$icode$gsl_mark_code" "$2"` ]];then
case "$1" in
"stats")
((gsl_stat_icode++))
;;
"make")
echo -ne "\r\033[2K: Convrting Inline-Code... $icode"
gsl_icode="$gsl_mark_code$icode$gsl_mark_code"
gsl_html_icode="$gsl_html_icode_o$icode</code>"
for d in "${gsl_d[@]}"
do do
case "$icode" in case "${line:i-1:1}" in
*"$d"*) "$gsl_mark_code")
continue [[ "$gsl_icode_open" ]] \
&& gsl_html_line+="$gsl_html_icode_c" \
&& unset gsl_icode_open && continue
gsl_icode_open=true
gsl_html_line+="$gsl_html_icode_o"
;; ;;
*) *)
sed -i "s${d}${gsl_icode}${d}${gsl_html_icode}${d}" "$2" gsl_html_line+="${line:i-1:1}"
break
;; ;;
esac esac
done done
sed -i "${n}d" "$2"
;; sed -i "${n}i$gsl_html_line" "$2"
esac unset gsl_html_line
done < <(grep -n "$gsl_mark_code" "$2")
fi ;;
done < <(grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)" "$2") esac
} }
# awk '{ for ( i = 1; i < NF; ++i ) print NR,$i; }' "$2"

View File

@ -24,13 +24,13 @@ gsl__page_create_listing
gsl__do_italics "make" "$gsl_tmp_post" # First gsl__do_italics "make" "$gsl_tmp_post" # First
gsl__do_header "make" "$gsl_marker_link" "$gsl_post" gsl__do_header "make" "$gsl_marker_link" "$gsl_post"
gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post" gsl__do_header "make" "$gsl_marker_abbr" "$gsl_post"
gsl__do_strongs_bolds "make" "$gsl_tmp_post"
gsl__do_icode "make" "$gsl_tmp_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_header "make" "$gsl_marker_image" "$gsl_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"
#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
@ -135,12 +135,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" 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@}
}