Class: SiSU_AO_DocumentStructureExtract::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/ao_doc_str.rb

Instance Method Summary collapse

Constructor Details

#initialize(md, data) ⇒ Build

Returns a new instance of Build.



64
65
66
67
68
69
70
71
72
# File 'lib/sisu/ao_doc_str.rb', line 64

def initialize(md,data)
  @md,@data=md,data
  SiSU_AO_DocumentStructureExtract::Instantiate.new
  @pb=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page])
  @pbn=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new])
  @pbl=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line])
  @per=SiSU_AO_Persist::PersistDocStructExt.new
  @make=SiSU_Env::ProcessingSettings.new(@md)
end

Instance Method Details

#build_lines(type = :none) ⇒ Object



1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
# File 'lib/sisu/ao_doc_str.rb', line 1283

def build_lines(type=:none)
  lines=@data
  lines.each.map do |line|
    line=if line =~/\S/ \
    and line !~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|\}code)/ \
    and line !~/^(?:```[ ]+code(?:\.[a-z][0-9a-z_]+)?|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \
    and not line.is_a?(Hash) #watch
      @@counter+=1 if @per.code==:curls or @per.code==:tics
      line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}").
        gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}")
      line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case
      line=if line =~/(?:https?|file|ftp):\/\/\S+$/
        line.gsub(/\s*$/," #{Mx[:br_nl]}")
      else line.gsub(/\s*$/,"#{Mx[:br_nl]}")           #unless type=='code'
      end
    elsif line =~/^\s*$/
      line.gsub(/\s*$/,"#{Mx[:br_nl]}")
    else line
    end
    line
  end
end

#bullet_test(str) ⇒ Object



92
93
94
95
96
# File 'lib/sisu/ao_doc_str.rb', line 92

def bullet_test(str)
  (str=~/\*/) \
  ? true
  : false
end

#construct_idx_array_and_hash(idxraw) ⇒ Object



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
# File 'lib/sisu/ao_doc_str.rb', line 168

def construct_idx_array_and_hash(idxraw)
  idx_array_raw=idxraw.scan(/[^;]+/)
  idx_hash,idx_array,idx_lst={},[],[]
  idx_array_raw.each do |idx|
    idx=idx.strip
    idx_lst=case idx
    when /\S+?\s*:/
      idx_couplet_tmp=[]
      idx_couplet=idx.scan(/\s*[^:]+\s*/)
      if idx_couplet[1] =~/[|]/
        idx_couplet_tmp <<
          idx_couplet[0] <<
          idx_couplet[1].scan(/\s*[^|]+\s*/)
      else
        idx_couplet_tmp <<
          idx_couplet[0] <<
          [idx_couplet[1]]
      end
      idx_couplet=idx_couplet_tmp
    else [idx]
    end
    term_nodes=[]
    idx_lst.each do |term_node|
      case term_node
      when String
        term_node=
          term_node[0].chr.capitalize +
          term_node[1,term_node.length]
        term_node=(term_node =~/.+?[+]\d+/) \
        ? term_node
        : (term_node + '+0')
        term_nodes << term_node
        use,plus=rgx_idx_ocn_seg.match(term_node)[1,2]
        @use=use.strip
        unless idx_hash[@use] \
        and defined? idx_hash[@use]
          idx_hash[@use]=
            { sub: [], plus: plus }
        end
      when Array
        subterm_nodes=[]
        term_node.each do |subterm_node|
          subterm_node=(subterm_node =~/.+?[+]\d+/) \
          ? subterm_node
          : (subterm_node + '+0')
          subterm_nodes << subterm_node
          sub,sub_plus=rgx_idx_ocn_seg.match(subterm_node)[1,2]
          unless idx_hash[@use] \
          and defined? idx_hash[@use]
            idx_hash[@use]=
              { sub: [], plus: 0 }
          end
          idx_hash[@use][:sub] <<
            { sub.strip => { plus: sub_plus } }
        end
        term_nodes << subterm_nodes
      end
    end
    idx_array << term_nodes
  end
  {
    hash: idx_hash,
    array: idx_array,
  }
end

#endnote_test?(str) ⇒ Boolean

Returns:

  • (Boolean)


139
140
141
142
143
# File 'lib/sisu/ao_doc_str.rb', line 139

def endnote_test?(str)
  (str=~/~\{.+?\}~|~\[.+?\]~/) \
  ? true
  : false
end

#extract_structure_loop(data, tuned_file) ⇒ Object



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
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
# File 'lib/sisu/ao_doc_str.rb', line 233

def extract_structure_loop(data,tuned_file)
  data.each do |t_o|
    if t_o =~/^--([+~-])[#]$/
      h=case $1
      when /[+]/
        @per.ocn=:on
        {
          flag: :ocn_on,
        }
      when /[~]/
        @per.ocn=:ocn_off_headings_keep
        {
          flag: :ocn_off,
          mod: :headings_keep,
        }
      when /[-]/ #of particular relevance with level 1~ which is required to precede substantive text & used e.g. in html segmented text
        @per.ocn=:ocn_off_headings_dummy_lev1
        {
          flag: :ocn_off,
          mod: :headings_exclude,
        }
      else
        @per.ocn=:on
        {
          flag: :ocn_on,
        }
      end
      t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h)
      next
    end
    if t_o =~/^:[~](#{SiSU_is.language_list_regex?}|-)$/  # work with for identifying language of objects
      lng=$1
      h=case lng
      when /(?:#{SiSU_is.language_list_regex?})/
        @per.lng=:on
        @per.lng_is=lng.to_sym
        {
          flag: :lng_on,
          act:  lng.to_sym,
        }
      else # ^:~-
        if @per.lng==:on
          @per.lng=:off
          @per.lng_is=:doc_default
          {
            flag: :lng_off,
            act:  :doc_default,
          }
        end
      end
      t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_lng(h)
      next
    end
    t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @per.code==:off
    unless t_o =~/^(?:@\S+?:|%+)\s/                  # extract book index for paragraph if any
      idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m
        m=$1
        m=m.split(/[ ]*\n/).join(' ').
          gsub(/\s+([|:;])\s+/,'\1').
          gsub(/\s+([+]\d+)\s+/,'\1')
        t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
        idx_array_and_hash=construct_idx_array_and_hash(m)
        idx_array_and_hash[:hash]
      else nil
      end
    end
    if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \
    and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \
    and @per.code==:off \
    and @per.poem==:off \
    and @per.group==:off \
    and @per.block==:off \
    and @per.alt==:off \
    and @per.box==:off \
    and @per.table==:off
      t_o=case t_o
      when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/                                 #metadata, header
        if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m
          tag,obj=$1,$2
          @metadata[tag]=obj
        end
        t_o=nil
      when /^%+\s/                                     #comment
        t_o=if t_o=~/^%+\s+(.+)/
          h={ obj: $1 }
          SiSU_AO_DocumentStructure::ObjectComment.new.comment(h)
        else nil
        end
      when /^:?([A-D1-6])\~/                           #heading / lv
        lv=$1
        ln=ln_get(lv)
        t_o=if t_o=~/^:?[A-D1-6]\~\s+(.+)/m
          obj=$1
          note=endnote_test?(obj)
          obj,tags=extract_tags(obj)
          if @per.ocn==:ocn_off_headings_dummy_lev1 \
          or @per.ocn==:ocn_off_headings_keep
            unless obj =~ /[~-][#]\s*$/
              if @per.ocn==:ocn_off_headings_dummy_lev1 \
              and t_o =~/^1\~\S*\s+/m
                obj << ' -#'
              elsif @per.ocn==:ocn_off_headings_dummy_lev1 \
              or @per.ocn==:ocn_off_headings_keep
                obj << ' ~#'
              end
            end
          end
          h={
            lv: lv,
            ln: ln,
            obj: obj,
            idx: idx,
            tags: tags,
          }
          SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
        elsif t_o=~/^:?[A-D1-6]\~(\S+?)-\s+(.+)/m
          name,obj=$1,$2
          note=endnote_test?(obj)
          obj,tags=extract_tags(obj)
          if @per.ocn==:ocn_off_headings_dummy_lev1 \
          or @per.ocn==:ocn_off_headings_keep
            unless obj =~ /[~-][#]\s*$/
              if @per.ocn==:ocn_off_headings_dummy_lev1 \
              and t_o =~/^1\~\S*\s+/m
                obj << ' -#'
              elsif @per.ocn==:ocn_off_headings_dummy_lev1 \
              or @per.ocn==:ocn_off_headings_keep
                obj << ' ~#'
              end
            end
          end
          h={
            lv: lv,
            name: name,
            obj: obj,
            idx: idx,
            autonum_: false,
            tags: tags,
          }
          SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
        elsif t_o=~/^:?[A-D1-6]\~(\S+)\s+(.+)/m
          name,obj=$1,$2
          note=endnote_test?(obj)
          obj,tags=extract_tags(obj,name)
          if @per.ocn==:ocn_off_headings_dummy_lev1 \
          or @per.ocn==:ocn_off_headings_keep
            unless obj =~ /[~-][#]\s*$/
              if @per.ocn==:ocn_off_headings_dummy_lev1 \
              and t_o =~/^1\~\S*\s+/m
                obj << ' -#'
              elsif @per.ocn==:ocn_off_headings_dummy_lev1 \
              or @per.ocn==:ocn_off_headings_keep
                obj << ' ~#'
              end
            end
          end
          h={
            lv: lv,
            name: name,
            obj: obj,
            idx: idx,
            tags: tags,
          }
          SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
        else nil
        end
      when /^_(?:[1-9]!?|[1-9]?\*)\s+/                  #indented and/or bullet paragraph
        t_o=if t_o=~/^(_(?:[1-9]?\*|[1-9]!?)\s+)(.+)/m
          tst,obj=$1,$2
          if t_o=~/^_[1-9]!\s+.+/m
            hang,indent,obj=hang_and_indent_def_test(tst,obj)
          else
            hang,indent=hang_and_indent_test(tst)
          end
          bullet=bullet_test(tst)
          image=image_test(obj)
          note=endnote_test?(obj)
          obj,tags=extract_tags(obj)
          unless obj=~/\A\s*\Z/m
            if @per.ocn==:ocn_off_headings_dummy_lev1 \
            or @per.ocn==:ocn_off_headings_keep
              unless obj =~ /[~-][#]\s*$/
                obj << ' ~#'
              end
            end
            h={
              bullet_: bullet,
              hang: hang,
              indent: indent,
              obj: obj,
              idx: idx,
              note_: note,
              image_: image,
              tags: tags,
              quote: quotes?,
            }
            SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
          end
        else nil
        end
      when /^_[0-9]?_[0-9]!?\s+/                  #hanging indent paragraph
        t_o=if t_o=~/^(_[0-9]?_[0-9]!?\s+)(.+)/m
          tst,obj=$1,$2
          if t_o=~/^_[0-9]?_[0-9]!\s+.+/m
            hang,indent,obj=hang_and_indent_def_test(tst,obj)
          else
            hang,indent=hang_and_indent_test(tst)
          end
          image=image_test(obj)
          note=endnote_test?(obj)
          obj,tags=extract_tags(obj)
          unless obj=~/\A\s*\Z/m
            if @per.ocn==:ocn_off_headings_dummy_lev1 \
            or @per.ocn==:ocn_off_headings_keep
              unless obj =~ /[~-][#]\s*$/
                obj << ' ~#'
              end
            end
            h={
              hang: hang,
              indent: indent,
              obj: obj,
              idx: idx,
              note_: note,
              image_: image,
              tags: tags,
              quote: quotes?,
            }
            SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
          end
        else nil
        end
      when /^<(?:br)?:(?:pa?r|o(?:bj|---)?)>\s*$/      #[br:par] #[br:obj]
        SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_obj])
      when /^(?:-\\\\-|<:pb>)\s*$/                                #[br:pg]
        SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page],:markup)
      when /^(?:=\\\\=|<:pn>)\s*$/                                #[br:pgn]
        SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new],:markup)
      when /^-\.\.-\s*$/                                          #[br:pgl]
        SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line],:markup)
      else                                             #paragraph
        image=image_test(t_o)
        note=endnote_test?(t_o)
        obj,tags=extract_tags(t_o)
        if @per.ocn==:ocn_off_headings_dummy_lev1 \
        or @per.ocn==:ocn_off_headings_keep
          unless obj =~ /[~-][#]\s*$/
            obj << ' ~#'
          end
        end
        unless obj=~/\A\s*\Z/m
          h={
            bullet_: false,
            indent: 0,
            hang: 0,
            obj: obj,
            idx: idx,
            note_: note,
            image_: image,
            tags: tags,
            quote: quotes?,
          }
          t_o=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
        end
        t_o=SiSU_AO_DocumentStructureExtract::Structure.new(@md).structure_markup(t_o) #must happen earlier, node info etc. require
      end
    elsif @per.code==:off
      if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/
        @per.code=case t_o
        when /^code(?:\.[a-z][0-9a-z_]+)?\{/ then :curls
        when /^```[ ]+code/                  then :tics
        else                                 @per.code #error
        end
        @per.lngsyn=if t_o =~/^(?:code\.[a-z][0-9a-z_]+\{|```[ ]+code\.[a-z_]+)/
          case t_o
          when /^code\.([a-z][0-9a-z_]+)\{/
            :"#{$1}"
          when /^```[ ]+code\.([a-z][0-9a-z_]+)/
            :"#{$1}"
          else :txt
          end
        else :txt
        end
        @@counter=1
        @codeblock_numbered=
          (t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) \
          ? true
          : false
        @num_id[:code_block] +=1
        h={
          is_for: :code,
          obj: '',
          sym: :code_block_open,
          num: @num_id[:code_block],
          syntax: @per.lngsyn,
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      elsif t_o =~/^(?:poem\{|```[ ]+poem)/
        @per.poem=case t_o
        when /^poem\{/        then :curls
        when /^```[ ]+poem/   then :tics
        else                  @per.poem #error
        end
        @num_id[:poem] +=1
        h={
          is_for: :poem,
          obj: '',
          sym: :poem_open,
          num: @num_id[:poem],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        tuned_file << t_o
      elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/
        @per.box=case t_o
        when /^box\{/         then :curls
        when /^```[ ]+box/    then :tics
        else                       @per.box #error
        end
        @num_id[:box] +=1
        h={
          is_for: :box,
          obj: '',
          sym: :box_open,
          num: @num_id[:box],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        tuned_file << t_o
      elsif t_o =~/^(?:group\{|```[ ]+group)/
        @per.group=case t_o
        when /^group\{/       then :curls
        when /^```[ ]+group/  then :tics
        else                       @per.group #error
        end
        @num_id[:group] +=1
        h={
          is_for: :group,
          obj: '',
          sym: :group_open,
          num: @num_id[:group],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        tuned_file << t_o
      elsif t_o =~/^(?:block\{|```[ ]+block)/
        @per.block=case t_o
        when /^block\{/       then :curls
        when /^```[ ]+block/  then :tics
        else                       @per.block #error
        end
        @num_id[:block] +=1
        h={
          is_for: :block,
          obj: '',
          sym: :block_open,
          num: @num_id[:block],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        tuned_file << t_o
      elsif t_o =~/^(?:alt\{|```[ ]+alt)/
        @per.alt=case t_o
        when /^alt\{/         then :curls
        when /^```[ ]+alt/    then :tics
        else                       @per.alt #error
        end
        @num_id[:alt] +=1
        h={
          is_for: :alt,
          obj: '',
          sym: :alt_open,
          num: @num_id[:alt],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        tuned_file << t_o
      elsif t_o =~/^`:quote_open`/
        @per.quote=:open
        @num_id[:quote] +=1
        h={
          is_for: :quote,
          obj: '',
          sym: :quote_open,
          num: @num_id[:quote],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        #tuned_file << t_o #% find second source, entered twice, should be once so closed off here
      elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/
        @num_id[:table] +=1
        h={
          is_for: :table,
          obj: '',
          sym: :table_open,
          num: @num_id[:table],
        }
        ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        tuned_file << ins_o
        if t_o=~/^table\{(?:~h)?\s+/
          @per.table=:curls
          @rows=''
          case t_o
          when /table\{~h\s+c(\d+);\s+(.+)/
            cols=$1
            col=$2.scan(/\d+/)
            heading=true
          when /table\{\s+c(\d+);\s+(.+)/
            cols=$1
            col=$2.scan(/\d+/)
            heading=false
          end
          @h={
            head_: heading,
            cols: cols,
            widths: col,
            idx: idx,
          }
        elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/
          @per.table=:tics
          @rows=''
          case t_o
          when /^```[ ]+table~h\s+c(\d+);\s+(.+)/
            cols=$1
            col=$2.scan(/\d+/)
            heading=true
          when /^```[ ]+table\s+c(\d+);\s+(.+)/
            cols=$1
            col=$2.scan(/\d+/)
            heading=false
          end
          @h={
            head_: heading,
            cols: cols,
            widths: col,
            idx: idx,
          }
        elsif t_o=~/^\{table(?:~h)?(?:\s+\d+;?)?\}\n.+\Z/m
          m1,m2,hd=nil,nil,nil
          tbl=/^\{table(?:~h)?(?:\s+\d+;?)?\}\n(.+)\Z/m.match(t_o)[1]
          hd=((t_o =~/^\{table~h/) ? true : false)
          tbl,tags=extract_tags(tbl)
          rws=tbl.split(/\n/)
          rows=''
          cols=nil
          rws.each do |r|
            cols=(cols ? cols : (r.scan('|').length) +1)
            r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}")       #r.gsub!(/\|/m,"#{Mx[:tc_p]}")
            rows += r + Mx[:tc_c]
          end
          col=[]
          if t_o =~/^\{table(?:~h)?\s+(\d+);?\}/       #width of col 1 given as %, usually when wider than rest that are even
            c1=$1.to_i
            width=(100 - c1)/(cols - 1)
            col=[ c1 ]
            (cols - 1).times { col << width }
          else                                         #all columns of equal width
            width=100.00/cols
            cols.times { col << width }
          end
          h={
            head_: hd,
            cols: cols,
            widths: col,
            obj: rows,
            idx: idx,
            tags: tags,
            num: @num_id[:table],
          }
          t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \
            unless h.nil?
          tuned_file << t_o
          h={
            is_for: :table,
            obj: '',
            sym: :table_close,
            num: @num_id[:table],
          }
          t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
          t_o
        elsif t_o=~/^```[ ]+table(?:~h)?\s+/
          m1,m2,hd=nil,nil,nil
          h=case t_o
          when /^```[ ]+table~h\s+(.+?)\n(.+)\Z/m      #two table representations should be consolidated as one
            m1,tbl,hd=$1,$2,true
          when /^```[ ]+table\s+(.+?)\n(.+)\Z/m        #two table representations should be consolidated as one
            m1,tbl,hd=$1,$2,false
          else nil
          end
          tbl,tags=extract_tags(tbl)
          col=m1.scan(/\d+/)
          rws=tbl.split(/\n/)
          rows=''
          rws.each do |r|
            r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}")       #r.gsub!(/\|/m,"#{Mx[:tc_p]}")
            rows += r + Mx[:tc_c]
          end
          h={
            head_: hd,
            cols: col.length,
            widths: col,
            obj: rows,
            idx: idx,
            tags: tags,
            num: @num_id[:table],
          }
          t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \
            unless h.nil?
          tuned_file << t_o
          h={
            is_for: :table,
            obj: '',
            sym: :table_close,
            num: @num_id[:table],
            }
          t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
          t_o
        elsif t_o=~/^\{table(?:~h)?\s+/
          m1,m2,hd=nil,nil,nil
          h=case t_o
          when /\{table~h\s+(.+?)\}\n(.+)\Z/m          #two table representations should be consolidated as one
            m1,tbl,hd=$1,$2,true
          when /\{table\s+(.+?)\}\n(.+)\Z/m            #two table representations should be consolidated as one
            m1,tbl,hd=$1,$2,false
          else nil
          end
          tbl,tags=extract_tags(tbl)
          col=m1.scan(/\d+/)
          rws=tbl.split(/\n/)
          rows=''
          rws.each do |r|
            r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}")       #r.gsub!(/\|/m,"#{Mx[:tc_p]}")
            rows += r + Mx[:tc_c]
          end
          h={
            head_: hd,
            cols: col.length,
            widths: col,
            obj: rows,
            idx: idx,
            tags: tags,
            num: @num_id[:table],
          }
          t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \
            unless h.nil?
          tuned_file << t_o
          h={
            is_for: :table,
            obj: '',
            sym: :table_close,
            num: @num_id[:table],
          }
          t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
          t_o
        end
      end
      t_o
    end
    if @per.table==:curls or @per.table==:tics
      if (@per.table==:curls \
      and t_o =~/^\}table/) \
      or (@per.table==:tics \
      and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
        @per.table=:off
        headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx]
        @h={
          head_: headings,
          cols: columns,
          widths: widths,
          idx: idx,
          obj: @rows,
        }
        t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h)
        tuned_file << t_o
        @h,@rows=nil,''
        h={
          is_for: :table,
          obj: '',
          sym: :table_close,
          num: @num_id[:table],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
        t_o
      else
        if t_o.is_a?(String) \
        and t_o !~/^(?:table\{|```[ ]+table)/
          t_o=t_o.gsub(/^\n+/m,'').
            gsub(/\n+/m,"#{Mx[:tc_p]}")
          @rows += t_o + Mx[:tc_c]
        end
        t_o=nil
      end
    end
    if @per.code==:curls \
    or @per.code==:tics
      if (@per.code==:curls \
      && t_o =~/^\}code/) \
      or (@per.code==:tics \
      && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m)
        @per.code=:off
        if @tuned_code[-1]
          @tuned_code[-1].
            gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
        end
        obj=@tuned_code.join("\n")
        tags=[]
        h={
          obj: obj,
          idx: idx,
          syntax: @per.lngsyn,
          tags: tags,
          num: @num_id[:code_block],
          number_: @codeblock_numbered,
        }
        @per.lngsyn=:txt
        t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h)
        @tuned_code=[]
        tuned_file << t_o
        h={
          is_for: :code,
          obj: '',
          sym: :code_close,
          num: @num_id[:code_block],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      end
      if (@per.code==:curls \
      || @per.code==:tics) \
      and t_o.is_a?(String)
        sub_array=t_o.dup + "#{Mx[:br_nl]}"
        @line_mode=[]
        sub_array.scan(/.+/) {|w| @line_mode << w if w =~/[\S]+/}
        t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(:code).join
        @tuned_code << t_o
        t_o=nil
      end
    elsif (@per.poem==:curls \
    || @per.poem==:tics) \
    or (@per.box==:curls \
    || @per.box==:tics) \
    or (@per.group==:curls \
    || @per.group==:tics) \
    or (@per.block==:curls \
    || @per.block==:tics) \
    or (@per.alt==:curls \
    || @per.alt==:tics) \
    or (@per.quote==:open \
    && t_o =~/`:quote_close`/m) #not
      if (@per.poem==:curls \
      && t_o =~/^\}poem$/m) \
      or (@per.poem==:tics \
      && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
        @per.poem=:off
        h={
          is_for: :poem,
          obj: '',
          idx: idx,
          sym: :poem_close,
          num: @num_id[:poem],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      elsif (@per.box==:curls \
      && t_o =~/^\}box/) \
      or (@per.box==:tics \
      && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
        @per.box=:off
        obj,tags=extract_tags(@tuned_block.join("\n"))
        h={
          obj: obj,
          idx: idx,
          tags: tags,
          num: @num_id[:box],
        }
        @tuned_block=[]
        t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h)
        tuned_file << t_o
        h={
          is_for: :box,
          obj: '',
          idx: idx,
          sym: :box_close,
          num: @num_id[:box],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      elsif (@per.group==:curls \
      && t_o =~/^\}group/) \
      or (@per.group==:tics \
      && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
        @per.group=:off
        obj,tags=extract_tags(@tuned_block.join("\n"))
        h={
          obj: obj,
          idx: idx,
          tags: tags,
          num: @num_id[:group],
        }
        @tuned_block=[]
        t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h)
        tuned_file << t_o
        h={
          is_for: :group,
          obj: '',
          sym: :group_close,
          num: @num_id[:group],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      elsif (@per.block==:curls \
      && t_o =~/^\}block/) \
      or (@per.block==:tics \
      && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
        @per.block=:off
        obj,tags=extract_tags(@tuned_block.join("\n"))
        h={
          obj: obj,
          idx: idx,
          tags: tags,
          num: @num_id[:block],
        }
        @tuned_block=[]
        t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h)
        tuned_file << t_o
        h={
          is_for: :block,
          obj: '',
          sym: :block_close,
          num: @num_id[:block],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      elsif (@per.alt==:curls \
      && t_o =~/^\}alt/) \
      or (@per.alt==:tics \
      && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
        @per.alt=:off
        obj,tags=extract_tags(@tuned_block.join("\n"))
        h={
          obj: obj,
          idx: idx,
          tags: tags,
          num: @num_id[:alt],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h)
        @tuned_block=[]
        tuned_file << t_o
        h={
          is_for: :alt,
          obj: '',
          sym: :alt_close,
          num: @num_id[:alt],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      elsif @per.quote==:open \
      and t_o =~/`:quote_close`/m
        @per.quote=:off
        h={
          is_for: :quote,
          idx: idx,
          obj: '',
          sym: :quote_close,
          num: @num_id[:quote],
        }
        t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h)
      elsif @per.quote==:open
        t_o,tags=extract_tags(t_o)
        h={
          indent: 1,
          obj: t_o,
          idx: idx,
          note_: note,
          image_: image,
          tags: tags,
          quote: quotes?,
        }
        SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
      end
      if (@per.poem==:curls \
      || @per.poem==:tics) \
      or (@per.group==:curls \
      || @per.group==:tics) \
      or (@per.alt==:curls \
      || @per.alt==:tics) \
      and t_o =~/\S/ \
      and t_o !~/^(?:\}(?:verse|code|box|alt|group|block)|(?:verse|code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|alt|group|block)\{)/ \
      and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic
        sub_array=t_o.dup
        @line_mode=sub_array.scan(/.+/)
        type=if @per.poem==:curls or @per.poem==:tics
          t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join
          poem=t_o.split(/\n\n/)
          poem.each do |v|
            v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n")
            obj,tags=extract_tags(v)
            h={
              obj: obj,
              tags: tags,
              num: @num_id[:poem],
            }
            t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h)
            tuned_file << t_o
          end
          :poem
        else :group
        end
      end
      @verse_count+=1 if @per.poem==:curls or @per.poem==:tics
    end
    if @per.code==:off
      if @per.poem==:curls or @per.poem==:tics \
      or @per.box==:curls or @per.box==:tics \
      or @per.group==:curls or @per.group==:tics \
      or @per.alt==:curls or @per.alt==:tics \
      or (@per.quote==:open and t_o =~/`:quote_close`/m)
        if t_o.is_a?(String)
          t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}").
            gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}").
            gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}")
          t_o=t_o + Mx[:br_nl] if t_o =~/\S+/
        elsif t_o.is==:group \
        || t_o.is==:block \
        || t_o.is==:alt \
        || t_o.is==:box \
        || t_o.is==:verse
          t_o.obj=t_o.obj.gsub(/\n/m,"#{Mx[:br_nl]}").
            gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}").
            gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}")
        end
        @tuned_block << t_o if t_o =~/\S+/
      else tuned_file << t_o
      end
    else tuned_file << t_o
    end
  end
  tuned_file
end

#extract_tags(str, nametag = nil) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/sisu/ao_doc_str.rb', line 144

def extract_tags(str,nametag=nil)
  tags=[]
  if str.nil?
  else
    if str =~/(?:^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/
      str=str.gsub(/(^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/i,
          "\\1#{Mx[:tag_o]}\\2#{Mx[:tag_c]}").
        gsub(/ [ ]+/i,' ')
      tags=str.scan(/#{Mx[:tag_o]}(\S+?)#{Mx[:tag_c]}/).flatten.uniq
      str=str.gsub(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks?
    end
    tags=nametag ? (tags << nametag) : tags
    tags.each do |t|
      t.gsub!(/[^a-z0-9._-]/,'')
    end
  end
  [
    str,
    tags,
  ]
end

#hang_and_indent_def_test(str1, str2) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/sisu/ao_doc_str.rb', line 115

def hang_and_indent_def_test(str1,str2)
  hang_indent=if str1=~/^_([1-9])[^_]/
    [$1,$1]
  elsif str1=~/^__([1-9])/
    [0,$1]
  elsif str1=~/^_([0-9])_([0-9])/
    [$1,$2]
  else
    [0,0]
  end
  obj=if str2 =~/^(.+?)\s+\\\\(?:\s+|\n)/
    str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/,
      "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2")
  else
    str2.gsub(/^(.+?)\n/,
      "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n")
  end
  hang,indent=hang_indent[0],hang_indent[1]
  [
    hang,
    indent,
    obj,
  ]
end

#hang_and_indent_test(str) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/sisu/ao_doc_str.rb', line 102

def hang_and_indent_test(str)
  hang_indent=if str=~/^_([1-9])[^_]/
    [$1,$1]
  elsif str=~/^__([1-9])/
    [0,$1]
  elsif str=~/^_([0-9])_([0-9])/
    [$1,$2]
  else
    [0,0]
  end
  hang,indent=hang_indent[0],hang_indent[1]
  [hang,indent]
end

#identify_partsObject



1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
# File 'lib/sisu/ao_doc_str.rb', line 1060

def identify_parts
  tuned_file=[]
  @tuned_block,@tuned_code=[],[]
  @@counter,@verse_count=0,0
  @num_id={
    code_block: 0,
    poem:       0,
    box:        0,
    group:      0,
    alt:        0,
    quote:      0,
    table:      0,
  }
  @metadata={}
  if @md.flag_auto_biblio \
  or @md.flag_biblio
    @data,bibliography=SiSU_AO_Appendices::Bibliography.new(@md,@data).biblio_extraction
  end
  if @md.flag_glossary
    @data,glossary=SiSU_AO_Appendices::Glossary.new(@md,@data).glossary_extraction
  end
  tuned_file=extract_structure_loop(@data,tuned_file)
  if @md.flag_endnotes
    tuned_file << @pb
    h={
      ln: 1,
      lc: 1,
      obj: 'Endnotes',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      ln: 4,
      lc: 2,
      obj: 'Endnotes',
      name: 'endnotes',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      obj: 'Endnotes'
    }
  end
  if @md.flag_glossary
    tuned_file << @pb
    h={
      ln: 1,
      lc: 1,
      obj: 'Glossary',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      ln: 4,
      lc: 2,
      obj: 'Glossary',
      name: 'glossary',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      obj: 'Glossary'
    }
    if glossary.length > 0
      tuned_file=extract_structure_loop(glossary,tuned_file)
    end
  end
  if @md.flag_auto_biblio
    tuned_file << @pb
    h={
      ln: 1,
      lc: 1,
      obj: 'References',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      ln: 4,
      lc: 2,
      obj: 'Bibliography',
      name: 'biblio',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      obj: 'Bibliography'
    }
    citenumber=0
    bibliography.each do |cite|
      citenumber +=1 if cite.is_a?(Hash)
      h={
        obj: cite[:obj],
        #obj: %{[#{citenumber}] } + cite[:obj],
        tags: [cite[:id]],
        hang: 0,
        indent: 2,
        ocn_: false,
      }
      tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
    end
  elsif @md.flag_biblio
    tuned_file << @pb
    h={
      ln: 1,
      lc: 1,
      obj: 'References',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      ln: 4,
      lc: 2,
      obj: 'Bibliography',
      name: 'biblio',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      obj: 'Bibliography'
    }
    if not bibliography.nil? \
    and bibliography.length > 0
      tuned_file=extract_structure_loop(bibliography,tuned_file)
    else
      tuned_file, citations =
        SiSU_AO_Appendices::Citations.new(@md,tuned_file).songsheet  # ao_appendices.rb
      citenumber=0
      citations.compact.each do |c|
        citenumber +=1 if c.is_a?(Hash)
        if c[:is]==:book
          h={
            obj: %{#{c[:author]}. /{#{c[:publication]}}/ (#{c[:year]})},
            #obj: %{[#{citenumber}] *{#{c[:author]}}* /{#{c[:publication]}}/ (#{c[:year]})},
            hang: 0,
            indent: 2,
            ocn_: false,
          }
          tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
        elsif c[:is]==:article
          h={
            obj: %{#{c[:author]}. /{"#{c[:title]}"}/ #{c[:publication]} editor #{c[:editor]} (#{c[:year]})},
            #obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:title]}"}/ #{c[:publication]} editor #{c[:editor]} (#{c[:year]})},
            hang: 0,
            indent: 2,
            ocn_: false,
          }
          tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
        end
      end
    end
  end
  if @md.book_idx
    tuned_file << @pb
    h={
      ln: 1,
      lc: 1,
      obj: 'Index',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      ln: 4,
      lc: 2,
      obj: 'Index',
      name: 'book_index',
      autonum_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      obj: 'Index'
    }
  end
  tuned_file << @pb
  if @make.build.metadata?
    h={
      ln: 1,
      lc: 1,
      obj: 'Metadata',
      autonum_: false,
      ocn_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
    h={
      ln: 4,
      lc: 2,
      obj: 'SiSU Metadata, document information',
      name: 'metadata',
      autonum_: false,
      ocn_: false,
    }
    tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h)
  end
  h={
    obj: 'eof',
  }
  meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.(@metadata)
  [tuned_file,meta,bibliography,glossary]
end

#image_test(str) ⇒ Object



87
88
89
90
91
# File 'lib/sisu/ao_doc_str.rb', line 87

def image_test(str)
  str=~/\{\s*\S+?\.png.+?\}https?:\/\/\S+/ \
  ? true
  : false
end

#ln_get(lv) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/sisu/ao_doc_str.rb', line 73

def ln_get(lv)
  case lv
  when /A/ then 0
  when /B/ then 1
  when /C/ then 2
  when /D/ then 3
  when /1/ then 4
  when /2/ then 5
  when /3/ then 6
  when /4/ then 7
  when /5/ then 8
  when /6/ then 9
  end
end

#meta_heading(h) ⇒ Object



1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
# File 'lib/sisu/ao_doc_str.rb', line 1266

def meta_heading(h)
  h={
    lv: h[:lv],
    ln: h[:ln],
    name: h[:name],
    obj: h[:obj],
    ocn: '0',
  }
  SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
end

#meta_para(str) ⇒ Object



1276
1277
1278
1279
1280
1281
1282
# File 'lib/sisu/ao_doc_str.rb', line 1276

def meta_para(str)
  h={
    obj: str,
    ocn_: false,
  }
  SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h)
end

#quotes?Boolean

Returns:

  • (Boolean)


97
98
99
100
101
# File 'lib/sisu/ao_doc_str.rb', line 97

def quotes?
  @per.quote==:open \
  ? true
  : false
end

#rgx_idx_ocn_segObject



165
166
167
# File 'lib/sisu/ao_doc_str.rb', line 165

def rgx_idx_ocn_seg
  @rgx_idx_ocn_seg=/(.+?)\s*[+](\d+)/
end

#table_rows_and_columns_array(table_str) ⇒ Object



1258
1259
1260
1261
1262
1263
1264
1265
# File 'lib/sisu/ao_doc_str.rb', line 1258

def table_rows_and_columns_array(table_str)
  table=[]
  table_str.split(/#{Mx[:tc_c]}/).each do |table_row|
    table_row_with_columns=table_row.split(/#{Mx[:tc_p]}/)
    table << table_row_with_columns
  end
  table
end