From e45aee1e25bf8c752036627d89575a7a49f2b78e Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Fri, 4 Mar 2022 14:50:56 +0100 Subject: [PATCH] Fix Italics, strongs, bolds in inline code --- var/lib/gsl/scripts/gsl__do_commons | 98 ++++++++++++++-------------- var/lib/gsl/scripts/gsl__post_makers | 10 +-- 2 files changed, 52 insertions(+), 56 deletions(-) diff --git a/var/lib/gsl/scripts/gsl__do_commons b/var/lib/gsl/scripts/gsl__do_commons index e111bc0..81d4d45 100644 --- a/var/lib/gsl/scripts/gsl__do_commons +++ b/var/lib/gsl/scripts/gsl__do_commons @@ -58,9 +58,6 @@ case "$1" in gsl_stat_bolds=0 ;; - "make") - echo -ne "\r\033[2K: Convrting Strongs & Bolds..." - ;; esac while read -r "strong" @@ -73,7 +70,13 @@ do ((gsl_stat_strongs++)) ;; "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_html_strong="$strong" 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 -echo -ne "\r\033[2K: Counting Bolds..." -while read -r "bold" +while IFS=: read -r "n" "bold" do if [[ "$bold" ]] && \ [[ `grep "$gsl_mark_bold$bold$gsl_mark_bold" "$2"` ]];then @@ -94,17 +96,25 @@ do case "$1" in "stats") ((gsl_stat_bolds++)) + echo -ne "\r\033[2K: Counting Bolds... $gsl_stat_bolds" ;; + "make") - echo -ne "\r\033[2K: Convrting Bold... $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="$bold" sed -i "s|$gsl_bold|$gsl_html_bold|g" "$2" ;; esac fi -done < <(grep -oP "(?<=$gsl_mark_bold).*?(?=$gsl_mark_bold)" "$2") +done < <(grep -oPn "(?<=$gsl_mark_bold).*?(?=$gsl_mark_bold)" "$2") case "$1" in "stats") @@ -123,12 +133,6 @@ 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" ]] && \ [[ `grep "$gsl_mark_italic$italic$gsl_mark_italic" "$2"` ]];then @@ -137,12 +141,17 @@ do ((gsl_stat_italics++)) ;; "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_html_italic="$italic" sed -i "s|$gsl_italic|$gsl_html_italic|g" "$2" ;; - esac fi done < <(grep -oPn "(?<=$gsl_mark_italic).*?(?=$gsl_mark_italic)" "$2") @@ -158,42 +167,35 @@ case "$1" in ;; "make") + echo + echo "Converting icodes..." gsl_html_icode_o="" - echo -ne "\r\033[2K: Convrting Inline-Codes..." - ;; -esac - -echo -ne "\r\033[2K: Counting Inline-Codes..." -while read -r "icode" -do - if [[ "$icode" ]] && \ - [[ `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" - - for d in "${gsl_d[@]}" - do - case "$icode" in - *"$d"*) - continue + gsl_html_icode_c="" + + while IFS=: read -r "n" "line" + do + unset gsl_icode_open + for i in $(seq 1 ${#line}) + do + case "${line:i-1:1}" in + "$gsl_mark_code") + [[ "$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" - break + gsl_html_line+="${line:i-1:1}" ;; esac done - - ;; - esac - - fi -done < <(grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)" "$2") + sed -i "${n}d" "$2" + sed -i "${n}i$gsl_html_line" "$2" + unset gsl_html_line + done < <(grep -n "$gsl_mark_code" "$2") + ;; +esac } +# awk '{ for ( i = 1; i < NF; ++i ) print NR,$i; }' "$2" diff --git a/var/lib/gsl/scripts/gsl__post_makers b/var/lib/gsl/scripts/gsl__post_makers index ff20d68..beeea0d 100644 --- a/var/lib/gsl/scripts/gsl__post_makers +++ b/var/lib/gsl/scripts/gsl__post_makers @@ -24,13 +24,13 @@ gsl__page_create_listing 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__do_strongs_bolds "make" "$gsl_tmp_post" +gsl__do_icode "make" "$gsl_tmp_post" gsl__make_titles 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__do_strongs_bolds "make" "$gsl_tmp_post" gsl__make_paragraphs -gsl__do_icode "make" "$gsl_tmp_post" #echo -ne "\r\033[2K: Searching and converting Block-Codes..." #gsl__check_bcodes @@ -135,12 +135,6 @@ gsl_html_long="$gsl_post_hf_1" 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@} -} -