Class: SiSU_Po4a::Source::Scroll

Inherits:
SiSU_Po4a::Source show all
Includes:
SiSU_Po4aUtils
Defined in:
lib/sisu/src_po4a_shelf.rb

Constant Summary collapse

@@endnotes =
{ para: [], end: [] }

Instance Method Summary collapse

Methods inherited from SiSU_Po4a::Source

#process_file, #read, #wrap_width_set

Methods included from SiSU_Object_Munge

#block_, #clean_text, #code_, #extract_endnotes, #footnotes_inline, #footnotes_ref_and_note, #i_ao_o_src_markup_restore, #i_ao_o_strip_markup, #i_src_o_strip_markup, #object_marks, #objects, #src_markup, #textface_marks, #textface_marks_po4a

Constructor Details

#initialize(fn, data_src, data_trn, md_src, md_trn, wrap_width) ⇒ Scroll

Returns a new instance of Scroll.



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/sisu/src_po4a_shelf.rb', line 210

def initialize(fn,data_src,data_trn,md_src,md_trn,wrap_width)
  @fn,@data_src,@data_trn,@md_src,@md_trn,@wrap_width=
   fn, data_src, data_trn, md_src, md_trn, wrap_width
  @md=(md_trn.nil?) \
  ? md_src
  : md_trn
  @tab="\t"
  @@endnotes_=(@md.opt.selections.str =~/--endnote/) \
  ? true
  : false    # --footnote
  @pot={
    body: [],
    open: [],
    close: [],
    head: [],
    metadata: [],
    tail: []
  }
end

Instance Method Details

#auto_translate?(set_to = nil) ⇒ Boolean

Returns:

  • (Boolean)


553
554
555
556
557
558
559
560
561
# File 'lib/sisu/src_po4a_shelf.rb', line 553

def auto_translate?(set_to=nil)
  @@auto_translation_=
  if @md.opt.act[:po4a_lang_trans][:set]==:on
    set_to \
    ? set_to
    : @@auto_translation_
  else :skip
  end
end

#auto_translation(src_txt, markup = :src) ⇒ Object

check for an appropriate request flag



562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/sisu/src_po4a_shelf.rb', line 562

def auto_translation(src_txt,markup=:src) # check for an appropriate request flag
  auto_translate?(:skip)
  begin
    src_txt_clean=clean_text(src_txt,markup)
    src_txt_clean=src_txt_clean.
      gsub(/\n/,' ').
      gsub(/"/,'\"').
      gsub(/([()])/,'\\\\\1')
    trans=''
    unless auto_translate? == :skip
      require 'timeout'
      Timeout::timeout(60) {
        trans=`trans -b -no-ansi en:#{@md.opt.f_pth[:lng_is]} #{src_txt_clean}`.strip
        unless trans.empty?
          trans + ' {[G.Tr]}http://translate.google.com'
        end
      }
    end
    trans
  rescue
    auto_translate?(:skip)
    p 'timeout issues with translation, skip remaining'
  end
end

#block(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object

% used to extract the structure of a document



746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# File 'lib/sisu/src_po4a_shelf.rb', line 746

def block(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
  mark="block{\\n\\n...\\n\\n}block"
  d=dob_src.is.to_s
  instruct=s_mark=''
  if @md.opt.act[:maintenance][:set]==:on
    instruct=%{\n# block text is a text block with an opening and closing marker, } \
    + %{the content of which may be wrapped}
    s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
  end
  desc="#{d}#{s_mark}#{instruct}"
  orig=dob_src.obj
  trans=((dob_trn=='') \
  || (dob_src.obj == dob_trn.obj)) \
  ? ''
  : "#{s_mark}#{dob_trn.obj}"
  if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
  and trans.empty? \
  and auto_translate?
    trans=auto_translation(dob_src.obj,:src)
  end
  util=pot_structure_wrap(desc,orig,trans)
  unwrapped=util.no_line_wrap_block
  @pot[:body] << unwrapped << br
end

#brObject



229
230
231
# File 'lib/sisu/src_po4a_shelf.rb', line 229

def br
  (@md.opt.selections.str =~/--dos/) ? "\r\n" : "\n"  # --unix
end

#code(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object

% used to extract the structure of a document



812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
# File 'lib/sisu/src_po4a_shelf.rb', line 812

def code(dob_src='',notes_s='',dob_trn='',notes_t='')      #% used to extract the structure of a document
  mark="code{\\n\\n...\\n\\n}code"
  d=dob_src.is.to_s
  instruct=s_mark=''
  if @md.opt.act[:maintenance][:set]==:on
    instruct=%{\n# codeblocks are a text block with an opening and closing marker, } \
    + %{the content of which should remain unwrapped}
    s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
  end
  desc="#{d}#{s_mark}#{instruct}"
  orig=dob_src.obj
  trans=(dob_trn=='') ? '' : dob_trn.obj
  util=pot_structure_wrap(desc,orig,trans)
  unwrapped=util.no_line_wrap_block
  @pot[:body] << unwrapped << br
end

#group(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object

% used to extract the structure of a document



770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
# File 'lib/sisu/src_po4a_shelf.rb', line 770

def group(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
  mark="group{\\n\\n...\\n\\n}group"
  d=dob_src.is.to_s
  instruct=s_mark=''
  if @md.opt.act[:maintenance][:set]==:on
    instruct=%{\n# group text is a text block with an opening and closing marker, } \
    + %{the content of which may be wrapped}
    s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
  end
  desc="#{d}#{s_mark}#{instruct}"
  orig=dob_src.obj
  trans=((dob_trn=='') \
  || (dob_src.obj == dob_trn.obj)) \
  ? ''
  : "#{s_mark}#{dob_trn.obj}"
  if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
  and trans.empty? \
  and auto_translate?
    trans=auto_translation(dob_src.obj,:src)
  end
  util=pot_structure_wrap(desc,orig,trans)
  unwrapped=util.no_line_wrap_block
  @pot[:body] << unwrapped << br
end

#heading(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object

% used to extract the structure of a document



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

def heading(dob_src='',notes_s='',dob_trn='',notes_t='')   #% used to extract the structure of a document
  lv=n=n3=nil
  lv=dob_src.ln
  n=lv - 1
  n3=lv + 2
  util=nil
  fn=(dob_src.name=~/[a-z\d]/i) ? dob_src.name : ''
  mark="#{dob_src.lv}~#{fn} "
  d="#{dob_src.is.to_s} (level #{dob_src.lv})"
  instruct=s_mark=''
  if @md.opt.act[:maintenance][:set]==:on
    instruct=%{\n# markup for headings is marker at the start of the line/object, } \
    + %{indicating the heading level, and if provided an associated name tag, } \
    + %{this heading is "#{mark}"}
    s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
  end
  desc="#{d}#{s_mark}#{instruct}"
  orig="#{s_mark}#{dob_src.obj}"
  trans=((dob_trn=='') \
  || (dob_src.obj == dob_trn.obj)) \
  ? ''
  : "#{s_mark}#{dob_trn.obj}"
  if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
  and trans.empty? \
  and auto_translate?
    trans=auto_translation(dob_src.obj,:src)
  end
  util=pot_structure_wrap(desc,orig,trans)
  wrapped=util.line_wrap
  @pot[:body] << wrapped << br # main text, contents, body KEEP
  if @@endnotes[:para] \
  and notes_s.length > 0 \
  and not @@endnotes_
    @pot[:body] << br
    wrap_endnotes(notes_s,notes_t)
  elsif @@endnotes[:para] \
  and @@endnotes_
    @pot[:body] << br*2
  end
end

#idx(dob_src = '', dob_trn = '') ⇒ Object

% used for book index but broken as original markup lost, already abstracted, fix



885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
# File 'lib/sisu/src_po4a_shelf.rb', line 885

def idx(dob_src='',dob_trn='')                             #% used for book index but broken as original markup lost, already abstracted, fix
  mark="={ ... }"
  instruct=s_mark=''
  if @md.opt.act[:maintenance][:set]==:on
    instruct=%{\n# the book index should be attached unwrapped to the preceding text block } \
    + %{(there should be a new line, but no empty line)}
    s_mark="\n# " + %{"\\n#{mark}\\n\\n"}
  end
  d='book-idx'
  desc="#{d}#{s_mark}#{instruct}"
  orig=pot_structure.idx_markup(dob_src.idx) #'={' + dob_src.idx + '}'
  trans=if defined? dob_trn.idx \
  and not dob_trn.idx.nil? \
  and not dob_trn.idx.empty?
    pot_structure.idx_markup(dob_trn.idx) #'={' + dob_trn.idx + '}'
  else ''
  end
  util=pot_structure_wrap(desc,orig,trans)
  unwrapped=util.no_line_wrap_block
  @pot[:body] << unwrapped << br
end

#idx_markup(idx) ⇒ Object



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

def idx_markup(idx)
  struct=['={']
  idx.sort.each do |x|
    x.each_with_index do |y,i0|
      case y
      when String
        struct << ';' unless struct[-1] =~/=\{/
        struct << y
        if x[i0+1].class == Hash \
        and x[i0+1][:sub].length > 0
          struct << ':'
        end
      when Hash
        if y[:plus].to_i > 0
          struct << '+' + y[:plus].to_s
        end
        if y[:sub].length > 0
          y[:sub].each_with_index do |z,i1|
            z.each_with_index do |a,i2|
              #p a
              if z.length > 0
                struct << a[0]
                if a[1][:plus].to_i > 0
                  struct << '+' + a[1][:plus].to_s
                end
                if (i1 + 1) < y[:sub].length
                  struct << '|'
                end
              end
            end
          end
        end
      end
    end
  end
  struct << '}'
  #puts struct.join
  struct.join
end

#markup(dob) ⇒ Object

dob_src,dob_trn


1055
1056
1057
1058
# File 'lib/sisu/src_po4a_shelf.rb', line 1055

def markup(dob)
  dob,notes=objects.textface_marks_po4a(dob,:separate)
  [dob,notes]
end

#para(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object

% used to extract the structure of a document



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

def para(dob_src='',notes_s='',dob_trn='',notes_t='')      #% used to extract the structure of a document
  util=nil
  wrapped=if dob_src.indent =~/[1-9]/ \
  and dob_src.indent == dob_src.hang
    s_mark=desc=orig=trans=''
    if dob_src.bullet_
      mark="_#{dob_src.indent}* "
      d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet"
      instruct=s_mark=''
      if @md.opt.act[:maintenance][:set]==:on
        instruct=%{\n# markup for indented bullet text is at the start of the line/object, } \
        + %{an underscore followed by the indent level and an asterisk "#{mark}"}
        s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
      end
      desc="#{d}#{s_mark}#{instruct}"
    else
      mark="_#{dob_src.indent} "
      d="#{dob_src.is.to_s}: indent #{dob_src.indent}"
      instruct=s_mark=''
      if @md.opt.act[:maintenance][:set]==:on
        instruct=%{\n# markup for indented text is at the start of the line/object, } \
        + %{an underscore followed by the indent level "#{mark}"}
        s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
      end
      desc="#{d}#{s_mark}#{instruct}"
    end
    orig="#{s_mark}#{dob_src.obj}"
    trans=((dob_trn=='') \
    || (dob_src.obj == dob_trn.obj)) \
    ? ''
    : "#{s_mark}#{dob_trn.obj}"
    if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
    and trans.empty? \
    and auto_translate?
      trans=auto_translation(dob_src.obj,:src)
    end
    util=pot_structure_wrap(desc,orig,trans)
  elsif dob_src.hang =~/[0-9]/ \
  and dob_src.indent != dob_src.hang
    s_mark=desc=orig=trans=''
    mark="_#{dob_src.hang}_#{dob_src.indent} "
    d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}"
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# markup for indented text with a first line indented } \
      + %{to a different level from the rest of the paragraph, } \
      + %{is at the start of the line/object, } \
      + %{an underscore and the first indent level } \
      + %{a second underscore and the indent level for the rest of the paragraph, "#{mark1}"}
      s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig="#{s_mark}#{dob_src.obj}"
    trans=((dob_trn=='') \
    || (dob_src.obj == dob_trn.obj)) \
    ? ''
    : "#{s_mark}#{dob_trn.obj}"
    if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
    and trans.empty? \
    and auto_translate?
      trans=auto_translation(dob_src.obj,:src)
    end
    util=pot_structure_wrap(desc,orig,trans)
  else
    s_mark=desc=orig=trans=''
    if dob_src.bullet_
      mark='_* '
      d="#{dob_src.is.to_s}: bullet"
      instruct=s_mark=''
      if @md.opt.act[:maintenance][:set]==:on
        instruct=%{\n# markup for indented text is at the start of the line/object, } \
        + %{an underscore followed by an asterisk "#{mark}"}
        s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
      end
      desc="#{d}#{s_mark}#{instruct}"
      orig="#{s_mark}#{dob_src.obj}"
      trans=((dob_trn=='') \
      || (dob_src.obj == dob_trn.obj)) \
      ? ''
      : "#{s_mark}#{dob_trn.obj}"
      if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
      and trans.empty? \
      and auto_translate?
        trans=auto_translation(dob_src.obj,:src)
      end
    else
      mark=''
      d=dob_src.is.to_s
      instruct=%{\n# regular paragraph, no special markup}
      if @md.opt.act[:maintenance][:set]==:on
        instruct="\n# "
        s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
      end
      desc="#{d}#{s_mark}#{instruct}"
      orig=dob_src.obj
      trans=((dob_trn=='') \
      || (dob_src.obj == dob_trn.obj)) \
      ? ''
      : "#{s_mark}#{dob_trn.obj}"
      if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
      and trans.empty? \
      and auto_translate?
        trans=auto_translation(dob_src.obj,:src)
      end
    end
    util=pot_structure_wrap(desc,orig,trans)
  end
  wrapped=util.line_wrap
  @pot[:body] << wrapped << br # main text, contents, body KEEP
  if @@endnotes[:para] \
  and notes_s.length > 0 \
  and not @@endnotes_
    @pot[:body] << br
    wrap_endnotes(notes_s,notes_t)
  elsif @@endnotes[:para] \
  and @@endnotes_
    @pot[:body] << br*2
  end
end

#pot_data(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object



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

def pot_data(dob_src='',notes_s='',dob_trn='',notes_t='')
  if dob_src.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
    if defined? dob_src.ocn \
    and dob_src.ocn.to_s =~/\d+/
      paranum=dob_src.ocn.to_s
      @p_num=SiSU_Po4aUtils::ParagraphNumber.new(paranum)
    end
    case dob_src.is
    when :heading
      pot_structure.heading(dob_src,notes_s,dob_trn,notes_t)
    when :para
      pot_structure.para(dob_src,notes_s,dob_trn,notes_t)
    when :group
      pot_structure.group(dob_src,notes_s,dob_trn,notes_t)
    when :block
      pot_structure.block(dob_src,notes_s,dob_trn,notes_t)
    when :verse
      pot_structure.verse(dob_src,notes_s,dob_trn,notes_t)
    when :code
      pot_structure.code(dob_src,notes_s,dob_trn,notes_t)
    when :table
      pot_structure.table(dob_src,notes_s,dob_trn,notes_t)
    end
    if defined? dob_src.idx \
    and not dob_src.idx.nil? \
    and not dob_src.idx.empty?
      pot_structure.idx(dob_src,dob_trn)
    end
    dob_src='' if (dob_src.obj =~/<a name="n\d+">/ \
    and dob_src.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
    if dob_src ## Clean Prepared Text
      dob_src.obj=dob_src.obj.gsub(/<!.+!>/,' ').
        gsub(/<:\S+>/,' ') if dob_src ## Clean Prepared Text
    end
  end
  #[dob_src,dob_trn]
end

#pot_markup(data_src, data_trn) ⇒ Object



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

def pot_markup(data_src,data_trn)
  #@endnotes,@copen,@pot_contents_close=Array.new(3){[]}
  a_l=if data_trn
  a_l=(data_src.length >= data_trn.length) \
  ? data_src.length
  : data_trn.length
  else
    data_src.length
  end
  s,t=0,0
  if @md.fns =~ /\.(?:(?:-|ssm\.)?sst|ssm)$/
    (data_trn.nil?) \
    ? 
    : 
  end
  0.upto(a_l-1) do |i|
    if data_trn
      unless data_src[s] \
      and data_trn[t]
        break
      end
      if data_src[s].of == :comment \
      and data_trn[t].of == :comment \
      and (data_src[s].is == data_trn[t].is)
        s+=1;t+=1
        next
      end
      if ((data_src[s].is == :comment) \
      || (data_trn[t].is == :comment)) \
      and (data_src[s].is != data_trn[t].is)
        if data_src[s].is == :comment
          if @md.opt.act[:maintenance][:set]==:on
            puts "src (comment):\n\t" \
            + data_src[s].obj
          end
          s+=1
          #next if data_src[s].is == :comment
        elsif data_trn[t].is == :comment
          if @md.opt.act[:maintenance][:set]==:on
            puts "trans (comment):\n\t" \
            + data_trn[t].obj
          end
          t+=1
          #next if data_trn[t].is == :comment
        end
      end
      if ((defined? data_src[s].ocn) \
      && (data_src[s].ocn.is_a?(Fixnum))) \
      and ((defined? data_trn[t].ocn) \
      && (data_trn[t].ocn.is_a?(Fixnum))) \
      and (data_src[s].ocn == data_trn[t].ocn)
        @m_s,@m_t=s,t
      elsif ((defined? data_src[s].ocn) \
      && (data_src[s].ocn.is_a?(Fixnum))) \
      and ((defined? data_trn[t].ocn) \
      && (data_trn[t].ocn.is_a?(Fixnum))) \
      and (data_src[s].ocn != data_trn[t].ocn)
        p '--- OCN ---'
        p 'mis-match'
        p data_src[s].ocn
        p data_src[s].obj
        p data_trn[t].ocn
        p data_trn[t].obj
        p '---'
        p 'previous match'
        p data_src[@m_s].ocn
        p data_src[@m_s].obj
        p data_trn[@m_t].ocn
        p data_trn[@m_t].obj
        exit
      elsif (((defined? data_src[s].ocn) \
      && (defined? data_trn[t].ocn)) \
      and data_src[s].ocn.class != data_trn[t].ocn.class)
        p '--- OCN class ---'
        p 'mis-match'
        p data_src[s].ocn if defined? data_src[s].ocn
        p data_src[s].obj
        p data_trn[t].ocn if defined? data_trn[t].ocn
        p data_trn[t].obj
        #p '---'
        #p 'previous match'
        #p data_src[@m_s].ocn
        #p data_src[@m_s].obj
        #p data_trn[@m_t].ocn
        #p data_trn[@m_t].obj
      #elsif (defined? data_src[s].ocn != defined? data_trn[t].ocn) \
      #and (data_src[s].ocn.nil? != data_trn[t].ocn.nil?)
      #  p '--- missing OCN? ---'
      #  p 'mis-match'
      #  p data_src[s].ocn if defined? data_src[s].ocn
      #  p data_src[s].obj
      #  p data_trn[t].ocn if defined? data_trn[t].ocn
      #  p data_trn[t].obj
      else
      end
    end
    notes_s,notes_t='',''
    data_src[s],notes_s=markup(data_src[s])
    if data_trn
      data_trn[t],notes_t=markup(data_trn[t])
      #data_src[s],data_trn[t]=pot_data(data_src[s],notes_s,data_trn[t],notes_t)
      pot_data(data_src[s],notes_s,data_trn[t],notes_t)
    else
      #data_src[s],nul=pot_data(data_src[s],notes_s)
      pot_data(data_src[s],notes_s)
    end
    s+=1;t+=1
  end
  @pot #watch
end

#pot_metadata_srcObject



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

def 
  @po4a_identify_type='type: SiSU doc' #'type: Plain text'
  meta_src=SiSU_Metadata::Summary.new(@md_src)
  w=[]
  w << [
    "#. #{@po4a_identify_type} - metadata: title",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..title.main,
    meta_src..title.sub,
    meta_src..title.edition,
    meta_src..title.note,
    meta_src..title.short,
    meta_src..title.language,
    meta_src..title.language_char,
    'msgstr ""',
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: creator",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..creator.head,
    meta_src..creator.author,
    meta_src..creator.contributor,
    meta_src..creator.illustrator,
    meta_src..creator.photographer,
    meta_src..creator.translator,
    meta_src..creator.audio,
    meta_src..creator.digitized_by,
    meta_src..creator.prepared_by,
    'msgstr ""',
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: rights",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..rights.head,
    meta_src..rights.copyright.text,
    meta_src..rights.copyright.translation,
    meta_src..rights.copyright.illustrations,
    meta_src..rights.copyright.photographs,
    meta_src..rights.copyright.digitization,
    meta_src..rights.copyright.audio,
    meta_src..rights.license,
    'msgstr ""',
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: classify",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..classify.head,
    meta_src..classify.subject,
    meta_src..classify.topic_register,
    meta_src..classify.loc,
    meta_src..classify.dewey,
    #meta_src.metadata_tags.notes.relation,
    #meta_src.metadata_tags.notes.type,
    #meta_src.metadata_tags.identifier.oclc,
    #meta_src.metadata_tags.identifier.isbn,
    'msgstr ""',
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: date",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..date.head,
    meta_src..date.added_to_site,
    meta_src..date.available,
    meta_src..date.created,
    meta_src..date.issued,
    meta_src..date.modified,
    meta_src..date.published,
    meta_src..date.valid,
    'msgstr ""',
  ]
  w << [
    "#. #{@po4a_identify_type} - processing, make instruction",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src.processing_tags.make.language,
    meta_src.processing_tags.make.headings,
    meta_src.processing_tags.make.num_top,
    meta_src.processing_tags.make.breaks,
    meta_src.processing_tags.make.emphasis,
    meta_src.processing_tags.make.bold,
    meta_src.processing_tags.make.italics,
    meta_src.processing_tags.make.texpdf_font,
    'msgstr ""',
  ]
  w.each do |y|
    z=''
    y.each do |x|
      if x
        z += x + "\n" if x =~/^#|^msg(?:id|str)/
        z += %{"#{x}"\n} if x =~/^@\S+?:(?: |$)/
        z += %{"#{x}"\n} if x =~/^\s+:\S+?: /
      end
    end
    @pot[:metadata] << z << br
    #puts z unless z.empty?
  end
end

#pot_metadata_src_trnObject



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

def 
  @po4a_identify_type='type: SiSU doc'
  #@po4a_identify_type='type: Plain text'
  meta_src=SiSU_Metadata::Summary.new(@md_src)
  meta_trn=SiSU_Metadata::Summary.new(@md_trn)
  w=[]
  w << [
    "#. #{@po4a_identify_type} - metadata: title",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..title.main,
    meta_src..title.sub,
    meta_src..title.edition,
    meta_src..title.note,
    meta_src..title.short,
    meta_src..title.language,
    meta_src..title.language_char,
    'msgstr ""',
    meta_trn..title.main,
    meta_trn..title.sub,
    meta_trn..title.edition,
    meta_trn..title.note,
    meta_trn..title.short,
    meta_trn..title.language,
    meta_trn..title.language_char,
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: creator",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..creator.head,
    meta_src..creator.author,
    meta_src..creator.contributor,
    meta_src..creator.illustrator,
    meta_src..creator.photographer,
    meta_src..creator.translator,
    meta_src..creator.audio,
    meta_src..creator.digitized_by,
    meta_src..creator.prepared_by,
    'msgstr ""',
    meta_trn..creator.head,
    meta_trn..creator.author,
    meta_trn..creator.contributor,
    meta_trn..creator.illustrator,
    meta_trn..creator.photographer,
    meta_trn..creator.translator,
    meta_trn..creator.audio,
    meta_trn..creator.digitized_by,
    meta_trn..creator.prepared_by,
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: rights",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..rights.head,
    meta_src..rights.copyright.text,
    meta_src..rights.copyright.translation,
    meta_src..rights.copyright.illustrations,
    meta_src..rights.copyright.photographs,
    meta_src..rights.copyright.digitization,
    meta_src..rights.copyright.audio,
    meta_src..rights.license,
    'msgstr ""',
    meta_trn..rights.head,
    meta_trn..rights.copyright.text,
    meta_trn..rights.copyright.translation,
    meta_trn..rights.copyright.illustrations,
    meta_trn..rights.copyright.photographs,
    meta_trn..rights.copyright.digitization,
    meta_trn..rights.copyright.audio,
    meta_trn..rights.license,
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: classify",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..classify.head,
    meta_src..classify.subject,
    meta_src..classify.topic_register,
    meta_src..classify.loc,
    meta_src..classify.dewey,
    #meta_src.metadata_tags.notes.relation,
    #meta_src.metadata_tags.notes.type,
    #meta_src.metadata_tags.identifier.oclc,
    #meta_src.metadata_tags.identifier.isbn,
    'msgstr ""',
    meta_trn..classify.head,
    meta_trn..classify.subject,
    meta_trn..classify.topic_register,
    meta_trn..classify.loc,
    meta_trn..classify.dewey,
    #meta_trn.metadata_tags.notes.relation,
    #meta_trn.metadata_tags.notes.type,
    #meta_trn.metadata_tags.identifier.oclc,
    #meta_trn.metadata_tags.identifier.isbn,
  ]
  w << [
    "#. #{@po4a_identify_type} - metadata: date",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src..date.head,
    meta_src..date.added_to_site,
    meta_src..date.available,
    meta_src..date.created,
    meta_src..date.issued,
    meta_src..date.modified,
    meta_src..date.published,
    meta_src..date.valid,
    'msgstr ""',
    meta_trn..date.head,
    meta_trn..date.added_to_site,
    meta_trn..date.available,
    meta_trn..date.created,
    meta_trn..date.issued,
    meta_trn..date.modified,
    meta_trn..date.published,
    meta_trn..date.valid,
  ]
  w << [
    "#. #{@po4a_identify_type} - processing, make instruction",
    "#: en/#{@md.fns}:#{SiSU_Po4aUtils::PotNumber.new.num}",
    'msgid ""',
    meta_src.processing_tags.make.language,
    meta_src.processing_tags.make.headings,
    meta_src.processing_tags.make.num_top,
    meta_src.processing_tags.make.breaks,
    meta_src.processing_tags.make.emphasis,
    meta_src.processing_tags.make.bold,
    meta_src.processing_tags.make.italics,
    meta_src.processing_tags.make.texpdf_font,
    'msgstr ""',
    meta_trn.processing_tags.make.language,
    meta_trn.processing_tags.make.headings,
    meta_trn.processing_tags.make.num_top,
    meta_trn.processing_tags.make.breaks,
    meta_trn.processing_tags.make.emphasis,
    meta_trn.processing_tags.make.bold,
    meta_trn.processing_tags.make.italics,
    meta_trn.processing_tags.make.texpdf_font,
  ]
  w.each do |y|
    z=''
    y.each do |x|
      if x
        z += x + "\n" if x =~/^#|^msg(?:id|str)/
        z += %{"#{x}"\n} if x =~/^@\S+?:(?: |$)/
        z += %{"#{x}"\n} if x =~/^\s+:\S+?: /
      end
    end
    @pot[:metadata] << z << br
    #puts z unless z.empty?
  end
end

#pot_structureObject



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

def pot_structure
  def heading(dob_src='',notes_s='',dob_trn='',notes_t='')   #% used to extract the structure of a document
    lv=n=n3=nil
    lv=dob_src.ln
    n=lv - 1
    n3=lv + 2
    util=nil
    fn=(dob_src.name=~/[a-z\d]/i) ? dob_src.name : ''
    mark="#{dob_src.lv}~#{fn} "
    d="#{dob_src.is.to_s} (level #{dob_src.lv})"
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# markup for headings is marker at the start of the line/object, } \
      + %{indicating the heading level, and if provided an associated name tag, } \
      + %{this heading is "#{mark}"}
      s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig="#{s_mark}#{dob_src.obj}"
    trans=((dob_trn=='') \
    || (dob_src.obj == dob_trn.obj)) \
    ? ''
    : "#{s_mark}#{dob_trn.obj}"
    if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
    and trans.empty? \
    and auto_translate?
      trans=auto_translation(dob_src.obj,:src)
    end
    util=pot_structure_wrap(desc,orig,trans)
    wrapped=util.line_wrap
    @pot[:body] << wrapped << br # main text, contents, body KEEP
    if @@endnotes[:para] \
    and notes_s.length > 0 \
    and not @@endnotes_
      @pot[:body] << br
      wrap_endnotes(notes_s,notes_t)
    elsif @@endnotes[:para] \
    and @@endnotes_
      @pot[:body] << br*2
    end
  end
  def para(dob_src='',notes_s='',dob_trn='',notes_t='')      #% used to extract the structure of a document
    util=nil
    wrapped=if dob_src.indent =~/[1-9]/ \
    and dob_src.indent == dob_src.hang
      s_mark=desc=orig=trans=''
      if dob_src.bullet_
        mark="_#{dob_src.indent}* "
        d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet"
        instruct=s_mark=''
        if @md.opt.act[:maintenance][:set]==:on
          instruct=%{\n# markup for indented bullet text is at the start of the line/object, } \
          + %{an underscore followed by the indent level and an asterisk "#{mark}"}
          s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
        end
        desc="#{d}#{s_mark}#{instruct}"
      else
        mark="_#{dob_src.indent} "
        d="#{dob_src.is.to_s}: indent #{dob_src.indent}"
        instruct=s_mark=''
        if @md.opt.act[:maintenance][:set]==:on
          instruct=%{\n# markup for indented text is at the start of the line/object, } \
          + %{an underscore followed by the indent level "#{mark}"}
          s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
        end
        desc="#{d}#{s_mark}#{instruct}"
      end
      orig="#{s_mark}#{dob_src.obj}"
      trans=((dob_trn=='') \
      || (dob_src.obj == dob_trn.obj)) \
      ? ''
      : "#{s_mark}#{dob_trn.obj}"
      if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
      and trans.empty? \
      and auto_translate?
        trans=auto_translation(dob_src.obj,:src)
      end
      util=pot_structure_wrap(desc,orig,trans)
    elsif dob_src.hang =~/[0-9]/ \
    and dob_src.indent != dob_src.hang
      s_mark=desc=orig=trans=''
      mark="_#{dob_src.hang}_#{dob_src.indent} "
      d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}"
      instruct=s_mark=''
      if @md.opt.act[:maintenance][:set]==:on
        instruct=%{\n# markup for indented text with a first line indented } \
        + %{to a different level from the rest of the paragraph, } \
        + %{is at the start of the line/object, } \
        + %{an underscore and the first indent level } \
        + %{a second underscore and the indent level for the rest of the paragraph, "#{mark1}"}
        s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
      end
      desc="#{d}#{s_mark}#{instruct}"
      orig="#{s_mark}#{dob_src.obj}"
      trans=((dob_trn=='') \
      || (dob_src.obj == dob_trn.obj)) \
      ? ''
      : "#{s_mark}#{dob_trn.obj}"
      if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
      and trans.empty? \
      and auto_translate?
        trans=auto_translation(dob_src.obj,:src)
      end
      util=pot_structure_wrap(desc,orig,trans)
    else
      s_mark=desc=orig=trans=''
      if dob_src.bullet_
        mark='_* '
        d="#{dob_src.is.to_s}: bullet"
        instruct=s_mark=''
        if @md.opt.act[:maintenance][:set]==:on
          instruct=%{\n# markup for indented text is at the start of the line/object, } \
          + %{an underscore followed by an asterisk "#{mark}"}
          s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
        end
        desc="#{d}#{s_mark}#{instruct}"
        orig="#{s_mark}#{dob_src.obj}"
        trans=((dob_trn=='') \
        || (dob_src.obj == dob_trn.obj)) \
        ? ''
        : "#{s_mark}#{dob_trn.obj}"
        if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
        and trans.empty? \
        and auto_translate?
          trans=auto_translation(dob_src.obj,:src)
        end
      else
        mark=''
        d=dob_src.is.to_s
        instruct=%{\n# regular paragraph, no special markup}
        if @md.opt.act[:maintenance][:set]==:on
          instruct="\n# "
          s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
        end
        desc="#{d}#{s_mark}#{instruct}"
        orig=dob_src.obj
        trans=((dob_trn=='') \
        || (dob_src.obj == dob_trn.obj)) \
        ? ''
        : "#{s_mark}#{dob_trn.obj}"
        if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
        and trans.empty? \
        and auto_translate?
          trans=auto_translation(dob_src.obj,:src)
        end
      end
      util=pot_structure_wrap(desc,orig,trans)
    end
    wrapped=util.line_wrap
    @pot[:body] << wrapped << br # main text, contents, body KEEP
    if @@endnotes[:para] \
    and notes_s.length > 0 \
    and not @@endnotes_
      @pot[:body] << br
      wrap_endnotes(notes_s,notes_t)
    elsif @@endnotes[:para] \
    and @@endnotes_
      @pot[:body] << br*2
    end
  end
  def block(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
    mark="block{\\n\\n...\\n\\n}block"
    d=dob_src.is.to_s
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# block text is a text block with an opening and closing marker, } \
      + %{the content of which may be wrapped}
      s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig=dob_src.obj
    trans=((dob_trn=='') \
    || (dob_src.obj == dob_trn.obj)) \
    ? ''
    : "#{s_mark}#{dob_trn.obj}"
    if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
    and trans.empty? \
    and auto_translate?
      trans=auto_translation(dob_src.obj,:src)
    end
    util=pot_structure_wrap(desc,orig,trans)
    unwrapped=util.no_line_wrap_block
    @pot[:body] << unwrapped << br
  end
  def group(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
    mark="group{\\n\\n...\\n\\n}group"
    d=dob_src.is.to_s
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# group text is a text block with an opening and closing marker, } \
      + %{the content of which may be wrapped}
      s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig=dob_src.obj
    trans=((dob_trn=='') \
    || (dob_src.obj == dob_trn.obj)) \
    ? ''
    : "#{s_mark}#{dob_trn.obj}"
    if @md.opt.f_pth[:lng_is] !=@md.opt.lng_base \
    and trans.empty? \
    and auto_translate?
      trans=auto_translation(dob_src.obj,:src)
    end
    util=pot_structure_wrap(desc,orig,trans)
    unwrapped=util.no_line_wrap_block
    @pot[:body] << unwrapped << br
  end
  def verse(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
    mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem"
    d=dob_src.is.to_s
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# verse are part of the text block described as a poem, } \
      + %{the first verse is preceeded by an opening marker, } \
      + %{and the last verse by a closing marker, } \
      + %{the content of which should remain unwrapped}
      s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig=dob_src.obj
    trans=(dob_trn=='') ? '' : dob_trn.obj
    util=pot_structure_wrap(desc,orig,trans)
    unwrapped=util.no_line_wrap_block
    @pot[:body] << unwrapped << br
  end
  def code(dob_src='',notes_s='',dob_trn='',notes_t='')      #% used to extract the structure of a document
    mark="code{\\n\\n...\\n\\n}code"
    d=dob_src.is.to_s
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# codeblocks are a text block with an opening and closing marker, } \
      + %{the content of which should remain unwrapped}
      s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig=dob_src.obj
    trans=(dob_trn=='') ? '' : dob_trn.obj
    util=pot_structure_wrap(desc,orig,trans)
    unwrapped=util.no_line_wrap_block
    @pot[:body] << unwrapped << br
  end
  def table(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
    mark="table{\\n\\n...\\n\\n}table"
    d=dob_src.is.to_s
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# tables are a text block with an opening and closing marker, } \
      + %{the content of which should remain unwrapped}
      s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig=dob_src.obj
    orig=orig.gsub(/#{Mx[:tc_c]}/,"\n")
    trans=(dob_trn=='') ? '' : dob_trn.obj
    trans=trans.gsub(/#{Mx[:tc_c]}/,"\n")
    util=pot_structure_wrap(desc,orig,trans)
    unwrapped=util.no_line_wrap_block
    @pot[:body] << unwrapped << br
  end
  def idx_markup(idx)
    struct=['={']
    idx.sort.each do |x|
      x.each_with_index do |y,i0|
        case y
        when String
          struct << ';' unless struct[-1] =~/=\{/
          struct << y
          if x[i0+1].class == Hash \
          and x[i0+1][:sub].length > 0
            struct << ':'
          end
        when Hash
          if y[:plus].to_i > 0
            struct << '+' + y[:plus].to_s
          end
          if y[:sub].length > 0
            y[:sub].each_with_index do |z,i1|
              z.each_with_index do |a,i2|
                #p a
                if z.length > 0
                  struct << a[0]
                  if a[1][:plus].to_i > 0
                    struct << '+' + a[1][:plus].to_s
                  end
                  if (i1 + 1) < y[:sub].length
                    struct << '|'
                  end
                end
              end
            end
          end
        end
      end
    end
    struct << '}'
    #puts struct.join
    struct.join
  end
  def idx(dob_src='',dob_trn='')                             #% used for book index but broken as original markup lost, already abstracted, fix
    mark="={ ... }"
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# the book index should be attached unwrapped to the preceding text block } \
      + %{(there should be a new line, but no empty line)}
      s_mark="\n# " + %{"\\n#{mark}\\n\\n"}
    end
    d='book-idx'
    desc="#{d}#{s_mark}#{instruct}"
    orig=pot_structure.idx_markup(dob_src.idx) #'={' + dob_src.idx + '}'
    trans=if defined? dob_trn.idx \
    and not dob_trn.idx.nil? \
    and not dob_trn.idx.empty?
      pot_structure.idx_markup(dob_trn.idx) #'={' + dob_trn.idx + '}'
    else ''
    end
    util=pot_structure_wrap(desc,orig,trans)
    unwrapped=util.no_line_wrap_block
    @pot[:body] << unwrapped << br
  end
  self
end

#pot_structure_wrap(desc, orig, trans, indent = 0, hang = 0) ⇒ Object



237
238
239
240
241
242
243
244
245
246
247
# File 'lib/sisu/src_po4a_shelf.rb', line 237

def pot_structure_wrap(desc,orig,trans,indent=0,hang=0)
  SiSU_Po4aUtils::Wrap.new(
    @md,
    orig,
    trans,
    desc,
    @wrap_width,
    indent,
    hang
  )
end

#publish(fn, pot) ⇒ Object



1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
# File 'lib/sisu/src_po4a_shelf.rb', line 1059

def publish(fn,pot)
  content=[]
  content << pot[:open]
  content << pot[:head]
  content << pot[:metadata]
  content << pot[:body]
  content << @@endnotes[:end] if @@endnotes_
  Output.new(fn,content,@md,@process).po4a
  @@endnotes={ para: [], end: [] }
end

#songsheetObject



232
233
234
235
236
# File 'lib/sisu/src_po4a_shelf.rb', line 232

def songsheet
  fn=@fn
  pot=pot_markup(@data_src,@data_trn)
  publish(fn,pot)
end

#table(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object

% used to extract the structure of a document



828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
# File 'lib/sisu/src_po4a_shelf.rb', line 828

def table(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
  mark="table{\\n\\n...\\n\\n}table"
  d=dob_src.is.to_s
  instruct=s_mark=''
  if @md.opt.act[:maintenance][:set]==:on
    instruct=%{\n# tables are a text block with an opening and closing marker, } \
    + %{the content of which should remain unwrapped}
    s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
  end
  desc="#{d}#{s_mark}#{instruct}"
  orig=dob_src.obj
  orig=orig.gsub(/#{Mx[:tc_c]}/,"\n")
  trans=(dob_trn=='') ? '' : dob_trn.obj
  trans=trans.gsub(/#{Mx[:tc_c]}/,"\n")
  util=pot_structure_wrap(desc,orig,trans)
  unwrapped=util.no_line_wrap_block
  @pot[:body] << unwrapped << br
end

#verse(dob_src = '', notes_s = '', dob_trn = '', notes_t = '') ⇒ Object

% used to extract the structure of a document



794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'lib/sisu/src_po4a_shelf.rb', line 794

def verse(dob_src='',notes_s='',dob_trn='',notes_t='')     #% used to extract the structure of a document
  mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem"
  d=dob_src.is.to_s
  instruct=s_mark=''
  if @md.opt.act[:maintenance][:set]==:on
    instruct=%{\n# verse are part of the text block described as a poem, } \
    + %{the first verse is preceeded by an opening marker, } \
    + %{and the last verse by a closing marker, } \
    + %{the content of which should remain unwrapped}
    s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"}
  end
  desc="#{d}#{s_mark}#{instruct}"
  orig=dob_src.obj
  trans=(dob_trn=='') ? '' : dob_trn.obj
  util=pot_structure_wrap(desc,orig,trans)
  unwrapped=util.no_line_wrap_block
  @pot[:body] << unwrapped << br
end

#wrap_endnotes(orig_notes = '', trn_notes = '') ⇒ Object



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

def wrap_endnotes(orig_notes='',trn_notes='')
  nt=@@endnotes_ ? 'endnote' : 'footnote'
  @fn=0
  a_l=orig_notes.length
  0.upto(a_l-1) do |i|
    @fn=if orig_notes[i].to_s =~/^\^~([\d*+]+)/ # provides endnote number within paragraph
      @fn += 1
    else @fn
    end
    d="#{nt} #{@fn}"
    mark="^~ "
    instruct=s_mark=''
    if @md.opt.act[:maintenance][:set]==:on
      instruct=%{\n# footnotes, the preferred sisu markup for a footnote is~{this is a footnote}~ } \
      + %{however, for translation a footnote reference marker in the text~^ } \
      + %{with a set of notes following the paragraph starting on a newline with "^~ this is a footnote", } \
      + %{is easier to deal with, if possible these should be converted back to~{inline notes}~}
      s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"}
    end
    desc="#{d}#{s_mark}#{instruct}"
    orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) \
    ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~'))
    : orig_notes[i].to_s
    trans=if trn_notes.is_a?(Array) \
    and trn_notes.length==orig_notes.length
      (trn_notes[i].to_s =~/^\^~[\d*+]+/) \
      ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~'))
      : trn_notes[i].to_s
    else ''
    end
    util=pot_structure_wrap(desc,orig,trans)
    wrap=util.line_wrap
    wrap=if wrap =~ /^\s*\^~[\d*+]+\s+.+?\s*\Z/m
      wrap.gsub(/^\s*(\^~[\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB
\\1 \\2
GSUB
                )
    else
      wrap.gsub(/^(.+)\Z/m, <<GSUB
\\1
GSUB
                )
    end
    @@endnotes[:para] << wrap
    @@endnotes[:end] << '' << wrap
  end
  @@endnotes[:para].each {|e| @pot[:body] << e << br}
  @@endnotes[:para]=[]
  @@endnotes
end