#!/bin/bash # file: gsl__do_commons # Folder: /var/lib/gsl/scripts # By echolib # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 #======================================================================= # Get NEEDED DATAS from HEADERS #======================================================================= gsl__get_needed_headers() { gsl_post_type=`gsl__get_header "$gsl_marker_type" "$gsl_post"` gsl_header_title=`gsl__get_header "$gsl_marker_title" "$gsl_post"` gsl_header_slug=`gsl__get_header "$gsl_marker_slug" "$gsl_post"` gsl_header_author=`gsl__get_header "$gsl_marker_author" "$gsl_post"` gsl_header_date=`gsl__get_header "$gsl_marker_date" "$gsl_post"` gsl_header_info=`gsl__get_header "$gsl_marker_info" "$gsl_post"` gsl_header_tags=`gsl__get_header "$gsl_marker_tags" "$gsl_post"` } #====================================================================== # Check | Make in Loop from header datas $1: process $2:marker $3:file #====================================================================== gsl__do_header() { unset ${!gsl_post_hf@} while read -r "gsl_header_content_line" do gsl__get_header_fields "$2" case "$1" in check) case "$2" in "$gsl_marker_link") gsl__check_link ;; "$gsl_marker_abbr") gsl__check_abbr ;; "$gsl_marker_file") gsl__check_file ;; "$gsl_marker_image") gsl__check_image ;; "$gsl_marker_code") gsl__check_fcode ;; esac ;; make) case "$2" in "$gsl_marker_link") gsl__make_link ;; "$gsl_marker_abbr") gsl__make_abbr ;; esac ;; esac done < <(gsl__get_header "$2" "$3") } #====================================================================== # Do Strongs && Bolds + Get STATS | $1: Process $2:File #====================================================================== gsl__do_strongs_bolds() { case "$1" in "stats") gsl_stat_strongs=0 gsl_stat_bolds=0 ;; "make") echo -ne "\r\033[2K: Convrting Strongs & Bolds..." ;; esac while read -r "strong" do if [[ "$strong" ]] && \ [[ `grep "$gsl_mark_strong$strong$gsl_mark_strong" "$2"` ]];then case "$1" in "stats") ((gsl_stat_strongs++)) ;; "make") echo -ne "\r\033[2K: Convrting 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" ;; esac fi done < <(grep -oP "(?<=$gsl_mark_strong).*?(?=$gsl_mark_strong)" "$2") # Bolds echo -ne "\r\033[2K: Counting Bolds..." while read -r "bold" do if [[ "$bold" ]] && \ [[ `grep "$gsl_mark_bold$bold$gsl_mark_bold" "$2"` ]];then case "$1" in "stats") ((gsl_stat_bolds++)) ;; "make") echo -ne "\r\033[2K: Convrting Bold... $bold" gsl_bold="$gsl_mark_bold$bold$gsl_mark_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") case "$1" in "stats") gsl_stat_bolds=$((gsl_stat_bolds - gsl_stat_strongs)) ;; esac } #====================================================================== # Do Italics + Get STATS | $1: Process $2:File #====================================================================== 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..." while read -r "italic" do if [[ "$italic" ]] && \ [[ `grep "$gsl_mark_italic$italic$gsl_mark_italic" "$2"` ]];then case "$1" in "stats") ((gsl_stat_italics++)) ;; "make") echo -ne "\r\033[2K: Convrting 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 -oP "(?<=$gsl_mark_italic).*?(?=$gsl_mark_italic)" "$2") } #====================================================================== # Do Italics + Get STATS | $1: Process $2:File #====================================================================== gsl__do_icode() { case "$1" in "stats") gsl_stat_icodes=0 ;; "make") 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 ;; *) sed -i "s${d}${gsl_icode}${d}${gsl_html_icode}${d}" "$2" break ;; esac done ;; esac fi done < <(grep -oP "(?<=$gsl_mark_code).*?(?=$gsl_mark_code)" "$2") }