Add ordered list with ø + readme

This commit is contained in:
Cyrille L 2022-04-14 14:14:42 +02:00
parent e22bc3e840
commit bf61976199
8 changed files with 119 additions and 28 deletions

View File

@ -387,7 +387,9 @@ _book: Esperanza 64
### Créer des listes ### Créer des listes
Dans l'article, utilisez ```=``` pour définir l'arborescence). Dans l'article...
- utilisez ```=``` pour définir l'arborescence d'une liste simple
- utilisez ```ø``` pour définir une liste ordonnée (alt+gr + o (FR azerty))
L'arborescence est "infinie". Chaque contenu de la liste *doit être sur la même ligne* L'arborescence est "infinie". Chaque contenu de la liste *doit être sur la même ligne*
``` ```

View File

@ -1,5 +1,5 @@
Package: egsl Package: egsl
Version: 0.0.20 Version: 0.0.21
Section: custom Section: custom
Priority: optional Priority: optional
Architecture: all Architecture: all

View File

@ -101,6 +101,7 @@ gsl_mark_strong='\*\*'
gsl_mark_italic='\/' gsl_mark_italic='\/'
gsl_mark_code="¤" gsl_mark_code="¤"
gsl_mark_list='=' gsl_mark_list='='
gsl_mark_listo="ø"
gsl_mark_blockquote='---' gsl_mark_blockquote='---'

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Version: 0.0.20 # Version: 0.0.21
# file: gsl # file: gsl
# Folder: /usr/local/bin # Folder: /usr/local/bin
# By echolib # By echolib
@ -269,7 +269,6 @@ case "$1" in
;; ;;
check|-C) check|-C)
gsl__check_nbr_posts
case "$2" in case "$2" in
-F) -F)
gsl_force_check=true gsl_force_check=true
@ -339,7 +338,6 @@ case "$1" in
;; ;;
make|-M) make|-M)
gsl__check_nbr_posts
gsl_process="wip" gsl_process="wip"
gsl_post_list="Add" gsl_post_list="Add"
case "$2" in case "$2" in
@ -409,6 +407,40 @@ case "$1" in
"$gsl_dir_domain_tpl/last-posts-list.html" "$gsl_dir_domain_tpl/last-posts-list.html"
;; ;;
list|-l)
! [[ "$2" ]] \
&& echo "! Missing argument: OPT=add|-A/remove|-R" \
&& exit
! [[ "$3" ]] \
&& echo "! Missing argument: post [FILE]" \
&& exit
gsl__if_file "$3" post
case "$2" in
add|-A) gsl_listing_process="add" ;;
remove|-R) gsl_listing_process="remove" ;;
*) echo "! Bad argument: $2 ? OPT=add|-A/remove|-R";exit ;;
esac
gsl__logs_print \
"$gsl_log_i" \
"Starting" \
"Process" \
"$1 ; $2 ; $3 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html"
gsl__loop_posts listing
gsl__logs_print \
"$gsl_log_i" \
"Stopping" \
"Process" \
"$1 ; $2 ; $3 from domain $gsl_find_domain" \
"$gsl_dir_domain_tpl/last-posts-list.html"
;;
www) www)
! [[ "$2" ]] \ ! [[ "$2" ]] \
&& echo "! Missing argument: OPT=add/remove" \ && echo "! Missing argument: OPT=add/remove" \
@ -451,7 +483,6 @@ case "$1" in
;; ;;
esac esac
gsl__check_nbr_posts
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"Starting" \ "Starting" \

View File

@ -387,7 +387,9 @@ _book: Esperanza 64
### Créer des listes ### Créer des listes
Dans l'article, utilisez ```=``` pour définir l'arborescence). Dans l'article...
- utilisez ```=``` pour définir l'arborescence d'une liste simple
- utilisez ```ø``` pour définir une liste ordonnée (alt+gr + o (FR azerty))
L'arborescence est "infinie". Chaque contenu de la liste *doit être sur la même ligne* L'arborescence est "infinie". Chaque contenu de la liste *doit être sur la même ligne*
``` ```

View File

@ -50,10 +50,10 @@ gsl_checker_war=true
if (( $gsl_post_hash == $gsl_db_post_hash ));then if (( $gsl_post_hash == $gsl_db_post_hash ));then
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_i" \
"Post" \ "Post" \
"Hash" \ "Hash" \
"$gsl_post checked with hash:$gsl_db_post_hash " \ "$gsl_post checked with hash:$gsl_db_post_hash" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
else else
@ -67,14 +67,16 @@ else
"New" \ "New" \
"$gsl_post not yet checked" \ "$gsl_post not yet checked" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
gsl_checker_war=true
;; ;;
*) *)
gsl__logs_print \ gsl__logs_print \
"$gsl_log_w" \ "$gsl_log_w" \
"Post" \ "Post" \
"Hash" \ "Hash" \
"$gsl_post Changed ($gsl_post_hash)" \ "$gsl_post Changed ($gsl_post_hash) !" \
"${PWD}/$gsl_post" "${PWD}/$gsl_post"
gsl_checker_war=true
;; ;;
esac esac

View File

@ -100,18 +100,32 @@ awk -v s="$1" \
# Convert List.Get first/last line item / repeat till no more mark # Convert List.Get first/last line item / repeat till no more mark
#====================================================================== #======================================================================
gsl__make_list() { gsl__make_list() {
! [[ `awk -v m="$gsl_mark_list" \ unset gsl_found_list
if [[ `awk -v m="$gsl_mark_list" \
'$1 == m {print $1;exit}' \ '$1 == m {print $1;exit}' \
"$gsl_tmp_post"` ]] \ "$gsl_tmp_post"` ]];then
&& return gsl_found_list=true
fi
gsl_last_line=`cat $gsl_tmp_post | wc -l` if [[ `awk -v m="$gsl_mark_listo" \
'$1 == m {print $1;exit}' \
"$gsl_tmp_post"` ]];then
gsl_found_list=true
fi
if [[ $gsl_found_list ]];then
gsl__make_list_read
gsl__make_list
fi
}
gsl__make_list_read() {
# Get block lists by line numbers From Content # Get block lists by line numbers From Content
gsl_last_line=`cat $gsl_tmp_post | wc -l`
while read -r "gsl_line" "gsl_content" while read -r "gsl_line" "gsl_content"
do do
case "$gsl_content" in case "$gsl_content" in
"$gsl_mark_list"*) "$gsl_mark_list"*|"$gsl_mark_listo"*)
! [[ $gsl_list ]] \ ! [[ $gsl_list ]] \
&& gsl_list=true \ && gsl_list=true \
&& gsl_list_o=$gsl_line \ && gsl_list_o=$gsl_line \
@ -121,6 +135,11 @@ do
&& gsl_list_c=$gsl_line \ && gsl_list_c=$gsl_line \
&& gsl__make_list_get_block \ && gsl__make_list_get_block \
&& break && break
case "$gsl_content" in
"$gsl_mark_list"*) gsl_html_uol="ul" ;;
"$gsl_mark_listo"*) gsl_html_uol="ol" ;;
esac
;; ;;
""|*) ""|*)
@ -189,14 +208,14 @@ do
elif (( $gsl_diff_pm_mn > 0 ));then elif (( $gsl_diff_pm_mn > 0 ));then
printf "%s%s\n" \ printf "%s%s\n" \
"" \ "" \
"<ul class=\"${gsl_site_css}_list-ul\">" \ "<$gsl_html_uol class=\"${gsl_site_css}_list-$gsl_html_uol\">" \
>> "$gsl_HTML_list" >> "$gsl_HTML_list"
printf "%s%s\n" \ printf "%s%s\n" \
"" \ "" \
"<li class=\"${gsl_site_css}_list-li ${gsl_site_css}_list-$mn\">$content</li>" \ "<li class=\"${gsl_site_css}_list-li ${gsl_site_css}_list-$mn\">$content</li>" \
>> "$gsl_HTML_list" >> "$gsl_HTML_list"
elif (( $gsl_diff_pm_mn < 0 ));then elif (( $gsl_diff_pm_mn < 0 ));then
printf '</ul>%.s\n' {1..eval $n} \ printf "</$gsl_html_uol>%.s\n" {1..eval $n} \
>> "$gsl_HTML_list" >> "$gsl_HTML_list"
printf "%s%s\n" \ printf "%s%s\n" \
"" \ "" \
@ -205,7 +224,7 @@ do
fi fi
done < <(cat -n "$gsl_file_block_list") done < <(cat -n "$gsl_file_block_list")
echo "</ul>" >> "$gsl_HTML_list" echo "</$gsl_html_uol>" >> "$gsl_HTML_list"
# Remove useless list in tmp_post # Remove useless list in tmp_post
gsl_list_rm_tl=$(( $gsl_list_c - $gsl_list_o )) gsl_list_rm_tl=$(( $gsl_list_c - $gsl_list_o ))

View File

@ -10,6 +10,16 @@
# ----------------------------------------------------------- # -----------------------------------------------------------
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
gsl__loop_posts() { gsl__loop_posts() {
gsl__check_nbr_posts
(( $gsl_nbr_posts == 0 )) \
&& gsl__logs_print \
"$gsl_log_i" \
"Posts" \
"Not found" \
"$gsl_nbr_posts post. Nothing to do in" \
"${PWD}" \
&& return
gsl__logs_print \ gsl__logs_print \
"$gsl_log_i" \ "$gsl_log_i" \
"Posts" \ "Posts" \
@ -57,8 +67,9 @@ do
"$gsl_log_w" \ "$gsl_log_w" \
"wip" \ "wip" \
"Delete" \ "Delete" \
"$gsl_post_type ; $gsl_post has changed" \ "$gsl_post_type ; $gsl_post has changed !" \
"$gsl_srv_wip_page" "$gsl_srv_wip_page"
gsl_checker_war=true
fi fi
if [[ -f "$gsl_file_db_post" ]];then if [[ -f "$gsl_file_db_post" ]];then
@ -67,8 +78,9 @@ do
"$gsl_log_w" \ "$gsl_log_w" \
"DB" \ "DB" \
"Delete" \ "Delete" \
"file ; $gsl_post has changed" \ "file ; $gsl_post has changed !" \
"$gsl_file_db_post" "$gsl_file_db_post"
gsl_checker_war=true
fi fi
fi fi
@ -116,6 +128,28 @@ do
esac esac
;; ;;
listing)
# Continue if post changed
[[ "$gsl_post_new_hash" ]] \
&& gsl__logs_print \
"$gsl_log_e" \
"Listing" \
"$gsl_listing_process" \
"file ; $gsl_post has changed !" \
"$gsl_file_db_post" \
&& continue
case "$gsl_listing_process" in
add)
echo "> Add $gsl_this_post to listing"
;;
rem)
echo "> Remove $gsl_this_post to listing"
;;
esac
;;
post-list) post-list)
case "$gsl_db_post_status" in case "$gsl_db_post_status" in
wip|www) wip|www)