#!/usr/bin/perl
use strict ;
use warnings ;
use Term::ANSIColor;
# *************************************************************************#
# Test the idpp application using the raw, unprocessed list/list.html file.#
# Copyright (c) 2006-2024 Mahlon R. Smith, The Software Samurai            #
#     GNU GPL copyright notice located in idpp.hpp                         #
# Developed under: Perl 5.38.2                                             #
# Updated: 01-Aug 2025                                                     #
# *************************************************************************#

   my $Title  = colored("  dolist                                            \n", 'bold underline blue');
   my $raw    = "list/list.html" ;           # raw (unprocessed) HTML file
   my $src    = "list.html" ;                # source copy of HTML file
   my $css    = "../infodoc-styles.css" ;    # target CSS style sheet
   my $idpp   = "./idpp" ;                   # post-processor application
   my $option = @ARGV[0] ;                   # option from command line

   if ( -e $raw )
   {
      system ( "clear" ) ;
      system ( "cp --preserve=all '$raw' '$src'" ) ;
      #print ( "Raw: '$raw' Source: '$src'\n" ) ;

      if ( not defined $option )       # Full automagic processing
      {
         system ( "'$idpp' -f'$css' '$src'" ) ;
      }
      elsif ( $option eq 'i' )         # Full interactive processing
      {
         print "full interactive\n" ;
         system ( "'$idpp' -f'$css' -i '$src'" ) ;
      }
      elsif ( $option eq 'b' )         # Automatic except for bullet lists
      {
         print "interactive bullet lists\n" ;
         system ( "'$idpp' -f'$css' --bullet_list=specify '$src'" ) ;
      }
      elsif ( $option eq 'e' )         # Automatic except for enumerated lists
      {
         print "interactive enumerated lists\n" ;
         system ( "'$idpp' -f'$css' --enum_list=specify '$src'" ) ;
      }
      elsif ( $option eq 't' )         # Automatic except for tables (and cartouche)
      {
         print "interactive tables and cartouche\n" ;
         system ( "'$idpp' -f'$css' --table_border=specify --cartouche=specify '$src'" ) ;
      }
      elsif ( $option eq 'k' )         # Automatic, with BOOK debugging option
      {
         print "book automatic\n" ;
         system ( "'$idpp' -f'$css' --book '$src'" ) ;
      }
      elsif ( $option eq 'c' )         # Automatic, with SKIP debugging option
      {
         if ( defined @ARGV[1] )
         {
            print "skip_count automatic\n" ;
            system ( "'$idpp' -f'$css' --skip='@ARGV[1]' '$src'" ) ;
         }
         else
         { print colored ( "  --skip option requires a count argument\n", 'bright_red' ) ; }
      }
      elsif ( $option eq 'v' )         # Automatic, with VERBOSE option
      {
         print "verbose automatic\n" ;
         system ( "'$idpp' -f'$css' '$src' -v" ) ;
      }
      elsif ( $option eq 's' )         # Interactive with SCAN debugging option
      {
         print "scan interactive\n" ;
                                       # test for range arguments
         if ( defined @ARGV[1] and defined @ARGV[2] )
         { system ( "'$idpp' -f'$css' -i --scan='@ARGV[1]','@ARGV[2]' '$src'" ) ; }
         else
         { print colored ( "  --scan option requires three arguments: s startline endline\n", 'bright_red' ) ; }
      }
      elsif ( $option eq 'p' )         # Automatic with STEP debugging option
      {
         # Note: list.html processing currently has no response file
         print ( "  $Title" ) ;
         print colored ( "  $src currently has no response file.\n", 'blue' ) ;
      }
      elsif ( $option eq 'P' )         # TEMP - '--no_paraentity' option only
      {  # This option will be removed if texi2any bug fixed
         print ( "  $Title" ) ;
         print colored( "Option: Strip Para Entities Only\n", 'blue' ) ;
         system ( "'$idpp' -f'$css' --no_paraentity '$src'" ) ;
      }
      else
      {
         print ( "  $Title" ) ;
         print colored ( "  no argument: full automatic processing\n", 'blue' ) ;
         print colored ( "  i: full interactive processing\n", 'blue' ) ;
         print colored ( "  b: interactive bullet list formatting\n", 'blue' ) ;
         print colored ( "  e: interactive enumerated list formatting\n", 'blue' ) ;
         print colored ( "  t: interactive table formatting\n", 'blue' ) ;
         print colored ( "  k: interactive with --book option\n", 'blue' ) ;
         print colored ( "  c: automatic with   --skip=n option\n", 'blue' ) ;
         print colored ( "  v: automatic with   -v (verbose)option\n", 'blue' ) ;
         print colored ( "  s: interactive with --scan='a,b' option\n", 'blue' ) ;
         print colored ( "  p: interactive with --step='a' option\n", 'blue' ) ;
         print colored ( "  P: strip all &para; --no_paraentity option\n", 'blue' ) ;
      }
   }
   else
   { print colored ( "  $raw Not Found!\n\n", 'bright_red' ) ; }
   exit ;
