aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/utils.org
blob: e709bcfe5800493e193dfa13db936b659ff3882b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
-*- mode: org -*-
#+TITLE:       sisu utils
#+DESCRIPTION: documents - structuring, various output representations & search
#+FILETAGS:    :sisu:utils:
#+AUTHOR:      Ralph Amissah
#+EMAIL:       [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT:   Copyright (C) 2015 - 2021 Ralph Amissah
#+LANGUAGE:    en
#+STARTUP:     content hideblocks hidestars noindent entitiespretty
#+OPTIONS:     H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t
#+PROPERTY:    header-args  :exports code
#+PROPERTY:    header-args+ :noweb yes
#+PROPERTY:    header-args+ :eval no
#+PROPERTY:    header-args+ :results no
#+PROPERTY:    header-args+ :cache no
#+PROPERTY:    header-args+ :padline no

* utils
** utils.rb

#+BEGIN_SRC ruby  :tangle "../lib/sisu/utils.rb"
# <<sisu_document_header>>
module SiSU_Utils
  class CodeMarker
    def initialize(line,file,color=:red)
      @line,@file,@color=line.to_s,file,color
    end
    def ansi(color=nil)
      @color=color ? color : @color
      c={}
      c[:on]=case @color
      when :red         then ANSI_C[:red]
      when :green       then ANSI_C[:green]
      when :yellow      then ANSI_C[:yellow]
      when :blue        then ANSI_C[:blue]
      when :fuchsia     then ANSI_C[:fuchsia]
      when :cyan        then ANSI_C[:cyan]
      when :inv_red     then ANSI_C[:inv_red]
      when :inv_green   then ANSI_C[:inv_green]
      when :inv_yellow  then ANSI_C[:inv_yellow]
      when :inv_blue    then ANSI_C[:inv_blue]
      when :inv_fuchsia then ANSI_C[:inv_fuchsia]
      when :inv_cyan    then ANSI_C[:inv_cyan]
      when :b_red       then ANSI_C[:b_red]
      when :b_green     then ANSI_C[:b_green]
      when :b_yellow    then ANSI_C[:b_yellow]
      when :b_blue      then ANSI_C[:b_blue]
      when :b_fuchsia   then ANSI_C[:b_fuchsia]
      when :b_cyan      then ANSI_C[:b_cyan]
      else                   ANSI_C[:red]
      end
      c[:off]= ANSI_C[:off]
      #ansi_color + @line.to_s + ansi_color_off + ' ' + @file.gsub(/([^\/]+$)/,"#{ansi_color}\\1#{ansi_color_off}")
      c
    end
    def var(v,x)
      h={ c: nil, m: '' }
      if v.is_a?(Hash)
        h[:c] = (defined? v[:c]) ? v[:c] : ''
        h[:m] = (defined? v[:m]) ? v[:m] : ''
      elsif (v.is_a?(Symbol) \
      and x.is_a?(String))
        if v.is_a?(Symbol)
          h[:c]=v
        elsif v.is_a?(String)
          h[:m]=v
        end
        if x.is_a?(String)
          h[:m]=x
        end
      elsif (v.is_a?(Symbol) \
      or v.is_a?(String))
        if v.is_a?(Symbol)
          h[:c]=v
        elsif v.is_a?(String)
          h[:m]=v
        end
      end
      h[:c] = (defined? h[:c]) ? h[:c] : ''
      h[:m] = (defined? h[:m]) ? h[:m] : ''
      h[:c]=ansi(h[:c])
      h[:m]=message(h[:m])
      h
    end
    def message(msg='')
      @message=(msg.nil? || msg.empty?) \
      ? ''
      : ' ' + msg
    end
    def set(v=nil,x=nil)
      v=var(v,x)
      file,path=File.basename(@file),File.dirname(@file)
      v[:c][:on] + @line + v[:c][:off] + ' ' \
      + path + '/' \
      + "#{v[:c][:on]}#{file}#{v[:c][:off]}" \
      + v[:m]
    end
    def mark(v=nil,x=nil)
      puts set(v,x)
    end
    def tell(v=nil,x=nil)
      puts set(v,x)
    end
    def report(v=nil,x=nil)
      puts set(v,x)
    end
    def ok(v=nil,x=nil)
      if (v.is_a?(Symbol) \
      and x.is_a?(String))
        x= '*OK* ' + x
      elsif v.is_a?(String)
        v='*OK* ' + v
        x=nil
      else
        v,x='*OK*',nil
      end
      puts set(v,x)
    end
    def warn(v=nil,x=nil)
      if (v.is_a?(Symbol) \
      and x.is_a?(String))
        x="\n  " + '*WARN* ' + x
      elsif v.is_a?(String)
        v="\n  " + '*WARN* ' + v
        x=nil
      else
        v,x='*WARN*',nil
      end
      puts set(v,x)
    end
    def error(v=nil,x=nil)
      if (v.is_a?(Symbol) \
      and x.is_a?(String))
        x="\n  " + '*ERROR* ' + x
      elsif v.is_a?(String)
        v="\n  " + '*ERROR* ' + v
        x=nil
      else
        v,x='*ERROR*',nil
      end
      STDERR.puts set(v,x)
    end
  end
  class Path
    def initialize(dir=Dir.pwd)
      @dir=dir
    end
    def base_markup(call_path=nil)
      call_path = call_path \
      ? call_path \
      : Dir.pwd
      (/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(call_path)[1]
    end
    def base_markup_stub
      m=/.+\/(?:src\/)?(\S+)/im
      base_markup[m,1]
    end
    def image_src
      if base_markup =~/sisupod\/doc[\/]?$/
        base_markup.gsub(/\/doc[\/]?$/,'/image')
      elsif FileTest.directory?("#{base_markup}/_sisu/image")
        "#{base_markup}/_sisu/image"
      end
    end
    def bmd
      base_markup
    end
  end
end
__END__
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark({ m: %{
  code: #{@@flag[:code]}, <-- close "#{t_o}"
}})
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark({ m: %{
  code: #{@@flag['code']}, <-- close "#{t_o}"
}, c: :green})
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark({ m: %{
  code: #{@@flag['code']}, open --> "#{t_o}"
}}) if t_o=~/^```/m
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark(%{ code: #{@@flag['code']}, open --> "#{t_o}" }) \
if t_o=~/^```/m
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("open -->")
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark("open -->")
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark("open -->",:green)
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:green,"open -->")
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark("open -->")
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:green)
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("open -->")
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark('open -->',:green)
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:red).mark
puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:red).set
puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set('',:green)
puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set('',:fuchsia)
puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__
puts "#{ANSI_C[:red]} #{__LINE__.to_s} #{ANSI_C[:off]} #{__FILE__}"
puts ANSI_C[:fuchsia] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:fuchsia]}\\1#{ANSI_C[:off]}")
puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:red]}\\1#{ANSI_C[:off]}")
#+END_SRC

** utils_spell.rb

#+BEGIN_SRC ruby  :tangle "../lib/sisu/utils_spell.rb"
# <<sisu_document_header>>
module SiSU_SpellUtility
  class Spell
    def initialize(input,filesrc,flg)
      @flg=flg
      @filename, @filetype = /(.+?)(\.\w\w\w0$)/.match(filesrc)[1,2] #.gsub(/\.\w\w\w0$/, "")
      @input=input
      @allwords=[]
      puts @filename
      @speller='aspell' # 'ispell'
      @dictionary='british'
      @lang='en_GB'
    end
    def check
      @input.each do |data|
        data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' ').
          gsub(/(&nbsp;|#{Mx[:nbsp]})/i,' ').
          gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' ').
          gsub(/(<==.+|<:\S+>|<!.+?!>|^@\S+?:.+|\{\{\{|~)/,' ').
          gsub(/(["|<>)(\n'`.;&_-]|\=)/,' ').
          gsub(/\b(altExternal|
            target|externalimg|
            srcimagebext|
            img|src|toc|pdf|
            cd|org|
            helvetica|roman
            )\b/i,' ').
          gsub(/EOF/,'')
        @words=data.scan(/\S+/)
        @words.each { |y| @allwords << y }
      end
      @allwords=@allwords.uniq
      if @flg =~ /S/
        File.open('/home/ralph/spell_error','a+') do |file| #fix
          file.puts %{\n\n[ #{@filename} ]}
        end
        @allwords.each { |y| puts y.inspect; system(%{cat #{y} | /usr/bin/#{@speller} -l -d #{@dictionary} >> ~/spell_error })}
      else
        @allwords.each { |y| sp=%x{echo #{y}|#{@speller} -l }; puts sp unless sp.empty?}
      end
    end
  end
end
__END__
#+END_SRC

** utils_response.rb

#+BEGIN_SRC ruby  :tangle "../lib/sisu/utils_response.rb"
# <<sisu_document_header>>
module SiSU_Response
  def available_selections_
    %{'yes', 'no', 'quit' or 'exit'; [ynqx]}
  end
  def response?(ask)
    response='redo'
    print ask + %{ [#{available_selections_}]: }
    response=File.new('/dev/tty').gets.strip
    case response
    when /^(?:y|yes)$/          then true
    when /^(?:n|no)$/           then false
    when /^(?:[qx]|quit|exit)$/ then exit
    else puts %{[please type: #{available_selections_}]}
      response?(ask)
    end
  end
  def query
    def selections_available_(selections=:strict)
      short_options=(selections == :strict) ? '' : '; [ynqx]'
      %{'yes', 'no', 'quit' or 'exit'#{short_options}}
    end
    def selection_options
      def response_strict(resp)
        case resp
        when /^(?:yes)$/          then true
        when /^(?:no)$/           then false
        when /^(?:quit|exit)$/    then exit
        else
          puts %{response was: #{resp}}
          puts %{[please type to select: #{selections_available_(:strict)}]}
          answer?('',:strict)
        end
      end
      def response_short(resp)
        case resp
        when /^(?:y|yes)$/          then true
        when /^(?:n|no)$/           then false
        when /^(?:[qx]|quit|exit)$/ then exit
        else
          puts %{response was: #{resp}}
          puts %{[please type to select: #{selections_available_(:short)}]}
          answer?('',:short)
        end
      end
      self
    end
    def answer?(ask,selections=:strict)
      resp='redo'
      print ask + %{PROCEED? [#{selections_available_(selections)}]: }
      resp=File.new('/dev/tty').gets.strip
      (selections==:strict) \
      ? selection_options.response_strict(resp)
      : selection_options.response_short(resp)
    end
    self
  end
end
__END__
#+END_SRC

** utils_composite.rb

#+BEGIN_SRC ruby  :tangle "../lib/sisu/utils_composite.rb"
# <<sisu_document_header>>
module SiSU_Composite_Doc_Utils
  def inserts_array(loadfilename)
    IO.readlines(loadfilename,'')
  end
  def insert_filename?(para)
    if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest
      url($1.strip)
    elsif para =~/^<<\s*(\S+?\.ss[it])$/
      $1.strip
    end
  end
  def extract_filenames(loadfilename,file_names_arr)
    file_names_arr << loadfilename
    ssi_files=[]
    if loadfilename =~/\S+?\.ss[im]$/
      inserts_array(loadfilename).each do |para|
        filen=insert_filename?(para)
        file_names_arr << filen
        if filen =~/\S+?\.ssi$/
          ssi_files << filen
        end
      end
    end
    ssi_files.each do |fn|
      extract_filenames(fn,file_names_arr)
    end
    file_names_arr.flatten.compact.uniq.sort
  end
  def composite_and_imported_filenames_array(loadfilename)
    file_names_arr=[]
    begin
      if FileTest.file?(loadfilename)
        if loadfilename =~/\S+?\.ss[itm]$/
          if (@opt.act[:verbose][:set]==:on \
          || @opt.act[:verbose_plus][:set]==:on \
          || @opt.act[:maintenance][:set]==:on)
            SiSU_Screen::Ansi.new(
              @opt.act[:color_state][:set],
              'loading:',
              loadfilename,
            ).txt_grey
          end
          file_names_arr=extract_filenames(loadfilename,file_names_arr)
        end
      end
      if (@opt.act[:verbose_plus][:set]==:on \
      || @opt.act[:maintenance][:set]==:on)
        p file_names_arr ;p file_names_arr.length
      end
      file_names_arr
    rescue
      SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
        __LINE__.to_s + ':' + __FILE__
      end
    ensure
    end
  end
end
__END__
#+END_SRC

** utils_screen_text_color.rb

#+BEGIN_SRC ruby  :tangle "../lib/sisu/utils_screen_text_color.rb"
# <<sisu_document_header>>
module SiSU_Screen
  class Color
    attr_accessor :off,:marker,:bold,:underline,:invert,:darkgrey_hi,:grey_hi,:pink_hi,:fuchsia_hi,:red_hi,:orange_hi,:yellow_hi,:brown_hi,:lightgreen_hi,:green_hi,:cyan_hi,:blue_hi,:navy_hi,:white,:white_bold,:grey,:pink,:fuchsia,:ruby,:red,:orange,:yellow,:brown,:green,:darkgreen,:cyan,:blue,:navy,:black
    def initialize(&block)
      instance_eval &block
    end
  end
  class Ansi < Color
    attr_reader :cX
    def initialize(color_state,*txt)
      @color_state,@txt=color_state,txt
      @color_instruct=txt[0]
      @cX=@@cX=if color_state==:on
        Color.new do
          self.off=self.white=self.white_bold=self.marker=self.bold=self.underline=self.invert=self.darkgrey_hi=self.grey_hi=self.pink_hi=self.fuchsia_hi=self.red_hi=self.orange_hi=self.yellow_hi=self.brown_hi=self.lightgreen_hi=self.green_hi=self.cyan_hi=self.blue_hi=self.navy_hi=self.grey=self.pink=self.fuchsia=self.ruby=self.red=self.orange=self.yellow=self.brown=self.green=self.darkgreen=self.cyan=self.blue=self.navy=self.black=''
        end
      else                                                                       #default set to colors on
        Color.new do
          self.off           = "\033[0m"
          self.white         = "\033[37m"
          self.white_bold    = "\033[1m"
          self.marker        = "\033[42m"
          self.bold          = "\033[1m"
          self.underline     = "\033[4m"
          self.invert        = "\033[7m"
          self.darkgrey_hi   = "\033[100m"
          self.grey_hi       = "\033[47m"
          self.pink_hi       = "\033[105m"
          self.fuchsia_hi    = "\033[45m"
          self.red_hi        = "\033[41m"
          self.orange_hi     = "\033[101m"
          self.yellow_hi     = "\033[103m"
          self.brown_hi      = "\033[43m"
          self.lightgreen_hi = "\033[102m"
          self.green_hi      = "\033[42m"
          self.cyan_hi       = "\033[106m"
          self.blue_hi       = "\033[104m"
          self.navy_hi       = "\033[44m"
          self.grey          = "\033[90m"
          self.pink          = "\033[95m"
          self.fuchsia       = "\033[35m"
          self.ruby          = "\033[31m"
          self.red           = "\033[91m" #check
          self.orange        = "\033[91m"
          self.yellow        = "\033[93m"
          self.brown         = "\033[33m"
          self.green         = "\033[92m"
          self.darkgreen     = "\033[32m"
          self.cyan          = "\033[36m"
          self.blue          = "\033[94m"
          self.navy          = "\033[34m"
          self.black         = "\033[30m"
        end
      end
    end
    def colors
      0.upto(109) {|i| print "\033[#{i}m 33[#{i}m \033[m"}
      puts ''
    end
    def color
      case @color_instruct
      when /invert/        then @cX.invert
      when /darkgrey_hi/   then @cX.darkgrey_hi
      when /grey_hi/       then @cX.grey_hi
      when /pink_hi/       then @cX.pink_hi
      when /fuchsia_hi/    then @cX.fuchsia_hi
      when /red_hi/        then @cX.red_hi
      when /orange_hi/     then @cX.orange_hi
      when /yellow_hi/     then @cX.yellow_hi
      when /brown_hi/      then @cX.brown_hi
      when /lightgreen_hi/ then @cX.lightgreen_hi
      when /green_hi/      then @cX.green_hi
      when /cyan_hi/       then @cX.cyan_hi
      when /blue_hi/       then @cX.blue_hi
      when /navy_hi/       then @cX.navy_hi
      when /white/         then @cX.white
      when /grey/          then @cX.grey
      when /pink/          then @cX.pink
      when /fuchsia/       then @cX.fuchsia
      when /ruby/          then @cX.ruby
      when /red/           then @cX.red
      when /orange/        then @cX.orange
      when /yellow/        then @cX.yellow
      when /brown/         then @cX.brown
      when /green/         then @cX.green
      when /darkgreen/     then @cX.darkgreen
      when /cyan/          then @cX.cyan
      when /blue/          then @cX.blue
      when /navy/          then @cX.navy
      when /close/         then @cX.off
      when /off/           then @cX.off
      end
    end
    def colorize
      case @color_instruct
      when /invert/        then puts "#{@cX.invert}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /darkgrey_hi/   then puts "#{@cX.darkgrey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /grey_hi/       then puts "#{@cX.grey_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /pink_hi/       then puts "#{@cX.pink_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /fuchsia_hi/    then puts "#{@cX.fuchsia_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /red_hi/        then puts "#{@cX.red_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /orange_hi/     then puts "#{@cX.orange_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /yellow_hi/     then puts "#{@cX.yellow_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /brown_hi/      then puts "#{@cX.brown_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /lightgreen_hi/ then puts "#{@cX.lightgreen_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /green_hi/      then puts "#{@cX.green_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /cyan_hi/       then puts "#{@cX.cyan_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /blue_hi/       then puts "#{@cX.blue_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /navy_hi/       then puts "#{@cX.navy_hi}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off} #{@cX.grey}#{@txt[3]}#{@cX.off}"
      when /bold/          then puts "#{@cX.bold}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /white/         then puts "#{@cX.off}#{@txt[1]} #{@txt[2]}"
      when /grey/          then puts "#{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /pink/          then puts "#{@cX.pink}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /fuchsia/       then puts "#{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /ruby/          then puts "#{@cX.ruby}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /red/           then puts "#{@cX.red}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /orange/        then puts "#{@cX.orange}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /yellow/        then puts "#{@cX.yellow}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /brown/         then puts "#{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /green/         then puts "#{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /darkgreen/     then puts "#{@cX.darkgreen}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /cyan/          then puts "#{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /blue/          then puts "#{@cX.blue}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      when /navy/          then puts "#{@cX.navy}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
      end
    end
    def sourcename(sourcefilename)
      @sourcefilename=sourcefilename
    end
    def basename(sourcefilename)
      @basename=sourcefilename.sub(/\.(?:(?:-|ssm\.)?sst|ssm)$/,'')
    end
    def sisu
    end
    def rescue
      STDERR.puts %{\t   #{@cX.orange}Rescued#{@cX.off} #{@cX.grey}#{yield if block_given?}\n\t   An#{@cX.off} #{@cX.fuchsia}ERROR#{@cX.off} #{@cX.grey}occurred, message:#{@cX.off} #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.brown}#{@txt[2]}#{@cX.off}}
    end
    def warn
      STDERR.puts "\t  #{@cX.brown}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}"
    end
    def error
      STDERR.puts "\t  #{@cX.fuchsia}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off}"
    end
    def error2
      STDERR.puts "\t  #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.fuchsia}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
    end
    def version
      puts "#{@cX.blue_hi}#{@txt[0]} #{@txt[1]}#{@cX.off} #{@cX.grey} (#{@txt[3]} [#{@txt[2]}])#{@txt[4]} &#{@cX.off} #{@cX.ruby}Ruby#{@cX.off} #{@cX.grey}(#{@txt[5]})#{@cX.off}\n"
    end
    def html3numbers
      puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } +
        %{#{@cX.grey}} +
        %{scroll only: #{@txt[1]}, seg only: #{@txt[2]},} +
        %{#{@cX.off} } +
        %{#{@cX.cyan}joint scroll & seg: #{@txt[3]},#{@cX.off}} +
        %{#{@cX.grey} } +
        %{nav only: #{@txt[4]}} +
        %{#{@cX.off}}
    end
    def html2numbers
      puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } +
        %{#{@cX.grey}} +
        %{scroll only: #{@txt[1]},} +
        %{#{@cX.off} } +
        %{#{@cX.cyan}seg only: #{@txt[2]},#{@cX.off}} +
        %{#{@cX.grey} } +
        %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} +
        %{#{@cX.off}}
    end
    def html1numbers
      puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } +
        %{#{@cX.cyan}scroll only: #{@txt[1]},#{@cX.off}} +
        %{#{@cX.grey} } +
        %{seg only: #{@txt[2]}, } +
        %{joint scroll & seg: #{@txt[3]}, nav only: #{@n_files_nav}} +
        %{#{@cX.off}}
    end
    def html0_numbers
      puts %{\t#{@cX.ruby}#{@txt[0]} files processed#{@cX.off}. } +
        %{#{@cX.grey}} +
        %{scroll only: #{@txt[1]}, seg only: #{@txt[2]}, joint scroll & seg: #{@txt[3]},} +
        %{#{@cX.off} } +
        %{#{@cX.cyan}nav only: #{@txt[4]}#{@cX.off}.}
    end
    def grey
      puts "#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}"
    end
    def txt_white
      puts "\t#{@cX.white}#{@txt[0]}#{@cX.off} #{@cX.white}#{@txt[1]}#{@cX.off}"
    end
    def txt_grey
      puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}"
    end
    def txt_cyan
      puts "\t#{@cX.cyan}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}"
    end
    def txt_blue
      puts "\t#{@cX.blue}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}"
    end
    def txt_red
      puts "\t#{@cX.red}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off}"
    end
    def txt_green
      puts "\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}"
    end
    def url #clean
      blue
    end
    def result
      puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.green}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off}"
    end
    def maintenance
      puts "\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.brown}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off}"
    end
    def instruct
      puts %{\t  #{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.cyan}#{@txt[1]}#{@cX.off} #{@cX.grey}#{@txt[2]}#{@cX.off} #{@cX.cyan}#{@txt[3]}#{@cX.off} #{@cX.grey}#{@txt[4]}#{@cX.off} "#{@cX.brown}#{@f}#{@cX.off}"}
    end
    def grey_open
      print @cX.grey
    end
    def p_off
      print @cX.off
    end
    def p_close
      print @cX.off
    end
    def flow
      puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t  #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def output
      puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t  #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def generic
      puts %{\t#{@cX.navy}#{@txt[0]} #{@txt[1]}#{@cX.off}. }
    end
    def files_processed
      puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}}
    end
    def print_blue
      print "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}"
    end
    def puts_blue
      puts "#{@cX.blue}#{@txt[0]} #{@txt[1]}#{@cX.off}"
    end
    def print_brown
      print "#{@cX.brown}#{@txt[0]}#{@cX.off}"
    end
    def blue_tab
      print  "\t#{@cX.blue}#{@txt[0]}#{@cX.off}\n"
    end
    def print_grey
      print "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}"
    end
    def puts_grey
      puts "#{@cX.grey}#{@txt[0]} #{@txt[1]}#{@cX.off}"
    end
    def puts_brown
      puts "#{@cX.brown}#{@txt[0]} #{@txt[1]}#{@cX.off}"
    end
    def grey_tab
      print "\t#{@cX.grey}#{@txt[0]}#{@cX.off}\n"
    end
    def green_title
      puts %{#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}}
    end
    def green_title_hi
      puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off}}
    end
    def green_hi_blue
      puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def blue_title_hi
      puts %{#{@cX.blue_hi}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def grey_title_hi
      puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def grey_title_grey_blue
      puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off}}
    end
    def dark_grey_title_hi
      puts %{#{@cX.darkgrey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def cyan_title_hi
      puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def cyan_hi_blue
      puts %{#{@cX.cyan_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def dbi_title
      puts %{#{@cX.blue_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.cyan}#{@cX.grey}#{@txt[1]}#{@cX.off*2} #{@cX.green}#{@txt[2]}#{@cX.off}}
    end
    def yellow_title_hi
      puts %{#{@cX.yellow_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def term_sheet_title
      puts %{\t#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.red_hi}#{@cX.black}#{@txt[1]}.#{@cX.off*2} }
    end
    def generic_number
      puts "#{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}#{@txt[1]}#{@cX.off}"
    end
    def tex_numbers
      puts %{  #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}tex/pdf files processed#{@cX.off}.}
    end
    def tex_info_numbers
      puts %{  #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}texinfo files processed#{@cX.off}.}
    end
    def lout_numbers
      puts %{  #{@cX.green}#{@n_lout}#{@cX.off} #{@cX.cyan}lout/pdf files processed#{@cX.off}.}
    end
    def parameters
    end
    def reserved
      puts %{ #{@cX.grey_hi}#{@cX.black}reserved#{@cX.off*2}}
    end
    def meta_verse_title
      puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} }
    end
    def meta_verse_title_v
      b=sourcename(@txt[0])
      puts %{#{@cX.green_hi}#{@cX.black}MetaVerse#{@cX.off*2} } +
        %{#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t  #{@cX.blue}~meta/#{b}.meta#{@cX.off}}
    end
    def meta_verse
      puts "\t#{@cX.grey}MetaVerse#{@cX.off}"
    end
    def meta_verse_skipped
      puts %{\t#{@cX.grey}MetaVerse: MarshalLoad (creation of metaVerse skipped)#{@cX.off}}
    end
    def meta_verse_load
      puts %{\t[ MetaVerse: MarshalLoad ]}
    end
    def html_title
      puts %{#{@cX.green_hi}#{@cX.black}HTML#{@cX.off*2}}
    end
    def html_output
      puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t  #{@cX.blue}#{@txt[1]}#{@cX.off}}
    end
    def segmented
      puts "\t#{@cX.grey}Seg#{@cX.off} #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}segments#{@cX.off}"
    end
  end
end
__END__
        Color.new do
          self.off           = "\033[0m"
          self.white         = "\033[37m"
          self.white_bold    = "\033[1m"
          self.marker        = "\033[42m"
          self.bold          = "\033[1m"
          self.underline     = "\033[4m"
          self.invert        = "\033[7m"
          self.darkgrey_hi   = "\033[100m"
          self.grey_hi       = "\033[47m"
          self.pink_hi       = "\033[105m"
          self.fuchsia_hi    = "\033[45m"
          self.red_hi        = "\033[41m"
          self.orange_hi     = "\033[101m"
          self.yellow_hi     = "\033[103m"
          self.brown_hi      = "\033[43m"
          self.lightgreen_hi = "\033[102m"
          self.green_hi      = "\033[42m"
          self.cyan_hi       = "\033[106m"
          self.blue_hi       = "\033[104m"
          self.navy_hi       = "\033[44m"
          self.grey          = "\033[90m"
          self.pink          = "\033[95m"
          self.fuchsia       = "\033[35m"
          self.ruby          = "\033[31m"
          self.red           = "\033[91m" #check
          self.orange        = "\033[91m"
          self.yellow        = "\033[93m"
          self.brown         = "\033[33m"
          self.green         = "\033[92m"
          self.darkgreen     = "\033[32m"
          self.cyan          = "\033[36m"
          self.blue          = "\033[94m"
          self.navy          = "\033[34m"
          self.black         = "\033[30m"
        end
# fewer colors
        Color.new do
          self.off           = "\033[0m"
          self.white         = "\033[0m"
          self.marker        = "\033[42m"
          self.bold          = "\033[1m"
          self.underline     = "\033[4m"
          self.invert        = "\033[7m"
          self.darkgrey_hi   = "\033[100m"
          self.grey_hi       = "\033[47m"
          self.pink_hi       = "\033[105m"
          self.fuchsia_hi    = "\033[45m"
          self.red_hi        = "\033[41m"
          self.orange_hi     = "\033[101m"
          self.yellow_hi     = "\033[103m"
          self.brown_hi      = "\033[43m"
          self.lightgreen_hi = "\033[102m"
          self.green_hi      = "\033[42m"
          self.cyan_hi       = "\033[106m"
          self.blue_hi       = "\033[104m"
          self.navy_hi       = "\033[44m"
          self.grey          = "\033[90m"
          self.pink          = "\033[95m"
          self.fuchsia       = "\033[35m"
          self.ruby          = "\033[31m"
          self.red           = "\033[31m" #check
          self.orange        = "\033[91m"
          self.yellow        = "\033[33m"
          self.brown         = "\033[33m"
          self.green         = "\033[32m"
          self.darkgreen     = "\033[32m"
          self.cyan          = "\033[36m"
          self.blue          = "\033[34m"
          self.navy          = "\033[34m"
          self.black         = "\033[30m"
        end
#+END_SRC

* document header

#+NAME: sisu_document_header
#+BEGIN_SRC text
encoding: utf-8
- Name: SiSU

  - Description: documents, structuring, processing, publishing, search
    utils

  - Author: Ralph Amissah
    <ralph.amissah@gmail.com>

  - Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
    2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019,
    2020, 2021, Ralph Amissah,
    All Rights Reserved.

  - License: GPL 3 or later:

    SiSU, a framework for document structuring, publishing and search

    Copyright (C) Ralph Amissah

    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the Free
    Software Foundation, either version 3 of the License, or (at your option)
    any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
    more details.

    You should have received a copy of the GNU General Public License along with
    this program. If not, see <http://www.gnu.org/licenses/>.

    If you have Internet connection, the latest version of the GPL should be
    available at these locations:
    <http://www.fsf.org/licensing/licenses/gpl.html>
    <http://www.gnu.org/licenses/gpl.html>

    <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>

  - SiSU uses:
    - Standard SiSU markup syntax,
    - Standard SiSU meta-markup syntax, and the
    - Standard SiSU object citation numbering and system

  - Homepages:
    <http://www.sisudoc.org>

  - Git
    <https://git.sisudoc.org/projects/>
    <https://git.sisudoc.org/projects/?p=software/sisu.git;a=summary>
    <https://git.sisudoc.org/projects/?p=markup/sisu-markup-samples.git;a=summary>
#+END_SRC