Class: SiSU_HTML_Format::FormatTextObject

Inherits:
Object
  • Object
show all
Includes:
SiSU_Parts_HTML
Defined in:
lib/sisu/html_format.rb

Direct Known Subclasses

FormatScroll, FormatSeg, FormatToc

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SiSU_Parts_HTML

#_url_path_image_base, #band1, #band2, #banner_band, #black, #blue_ink, #blue_tinge, #css, #grey, #grey_medium, #grey_pale, #home_button_only, #ico, #instrument_cover_band_scr, #instrument_cover_band_seg, #num, #num_css, #numless, #paragraph_font_small, #paragraph_font_tiny, #png_home, #png_home_button, #set_color, #set_face, #set_fonts, #set_size_endnote, #set_small, #set_tiny, #table1, #table2, #table_txt, #table_txt_r, #the_banner, #the_color, #the_font, #the_line_break, #the_margin, #the_nav, #the_png, #the_table_cellpad_box, #the_table_close, #the_url_decoration, #the_width, #txt_0, #txt_1, #txt_2, #txt_3, #txt_close, #txt_concordance, #txt_doc_link, #txt_homepage, #txt_manifest, #txt_open, #txt_toc_link, #white, #xml_close, #xml_open, #yellow_light

Methods included from SiSU_Parts_Generic

#footer_signature, #home, #home_txt, #i_choice, #i_home_button, #i_ico, #i_new, #rl_root, #root_http, #sisu, #sisu_txt, #sisudoc, #site, #the_icon, #the_text, #the_url, #txt_home, #txt_hp, #txt_hp_alias, #txt_signature, #urify, #url_close, #url_open

Constructor Details

#initialize(md, t_o) ⇒ FormatTextObject

Returns a new instance of FormatTextObject.



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

def initialize(md,t_o)
  @md,@t_o=md,t_o
  @make=SiSU_Env::ProcessingSettings.new(@md)
  if t_o.is_a?(Hash)
    @txt            =t_o[:txt]            || nil
    @ocn            =t_o[:ocn]            || nil
    @ocn_display    =t_o[:ocn_display]    || nil
    @headname       =t_o[:headname]       || nil
    @trailer        =t_o[:trailer]        || nil
    @endnote_part_a =t_o[:endnote_part_a] || nil
    @endnote_part_b =t_o[:endnote_part_b] || nil
    @lnk_url        =t_o[:lnk_url]        || nil
    @lnk_txt        =t_o[:lnk_txt]        || nil
    @format         =t_o[:format]         || nil
  elsif t_o.class.inspect =~/^(?:#<)?SiSU_AO_DocumentStructure/
    @dob=t_o if defined? t_o.is
    @named=nametags_seg(@dob)
    @txt=((defined? t_o.obj) ? t_o.obj : nil)
    @ocn=((defined? t_o.ocn) ? t_o.ocn.to_s : nil)
    @headname=((t_o.is==:heading and defined? t_o.name) ? t_o.name : nil)
  else
    if @md.opt.act[:maintenance][:set]==:on
      p t_o.class
      p caller
    end
  end
  @headnamed=(@headname ? %{<a id="h#{@headname}"></a>} : nil)
  if @txt and not @txt.empty?
    @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'')
  end
  @p_num=ParagraphNumber.new(@md,@ocn)
end

Instance Attribute Details

Returns the value of attribute banner.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def banner
  @banner
end

#format(tag, attrib) ⇒ Object

Returns the value of attribute format.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def format
  @format
end

#headnameObject

check whether used



893
894
895
# File 'lib/sisu/html_format.rb', line 893

def headname
  @headname
end

Returns the value of attribute link.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def link
  @link
end

#linknameObject

Returns the value of attribute linkname.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def linkname
  @linkname
end

#mdObject

Returns the value of attribute md.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def md
  @md
end

#ocnObject

Returns the value of attribute ocn.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def ocn
  @ocn
end

#p_numObject

Returns the value of attribute p_num.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def p_num
  @p_num
end

#paranumObject

Returns the value of attribute paranum.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def paranum
  @paranum
end

#t_oObject

Returns the value of attribute t_o.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def t_o
  @t_o
end

#tableObject

Returns the value of attribute table.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def table
  @table
end

#txtObject

Returns the value of attribute txt.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def txt
  @txt
end

#urlObject

Returns the value of attribute url.



836
837
838
# File 'lib/sisu/html_format.rb', line 836

def url
  @url
end

Instance Method Details

#altObject



950
951
952
# File 'lib/sisu/html_format.rb', line 950

def alt
  para_form_css('p','alt')
end

#blockObject



944
945
946
# File 'lib/sisu/html_format.rb', line 944

def block
  para_form_css('p','block')
end

#boldObject



962
963
964
# File 'lib/sisu/html_format.rb', line 962

def bold
  para_form_css('p','bold')
end

#bold_headingObject



1103
1104
1105
1106
1107
1108
1109
1110
# File 'lib/sisu/html_format.rb', line 1103

def bold_heading
  %{<p class="bold">
#{@txt}
  </p>
#{the_margin.num_css}
  &nbsp;&nbsp;&nbsp;
#{the_table_close}}
end

#bold_paraObject



1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/sisu/html_format.rb', line 1094

def bold_para
  %{#{the_margin.txt_0}
  <p class="bold">
#{@txt}
  </p>
#{the_margin.num_css}
  &nbsp;&nbsp;&nbsp;
#{the_table_close}}
end

#bulletObject



965
966
967
# File 'lib/sisu/html_format.rb', line 965

def bullet
  para_form_css('li','bullet')
end

#centerObject



959
960
961
# File 'lib/sisu/html_format.rb', line 959

def center
  para_form_css('p','center')
end

#center_boldObject



1120
1121
1122
# File 'lib/sisu/html_format.rb', line 1120

def center_bold
  %{<p class="centerbold">#{@txt}</p>\n}
end

#codeObject



956
957
958
# File 'lib/sisu/html_format.rb', line 956

def code
  para_form_css('p','code')
end

#dlObject

check :trailer



1073
1074
1075
# File 'lib/sisu/html_format.rb', line 1073

def dl #check :trailer
  "<dl><b>#{@txt}</b> #{@trailer}</dl>"
end

#endnote_bodyObject



903
904
905
906
907
908
909
# File 'lib/sisu/html_format.rb', line 903

def endnote_body
  %{
<p class="endnote">
  #{@txt}
</p>
}
end

#endnote_body_indentObject



910
911
912
913
914
915
916
# File 'lib/sisu/html_format.rb', line 910

def endnote_body_indent
  %{
  <p class="endnote_indent">
#{@txt}
  </p>
}
end

#groupObject



947
948
949
# File 'lib/sisu/html_format.rb', line 947

def group
  para_form_css('p','group')
end

#gsub_bodyObject

fix



1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
# File 'lib/sisu/html_format.rb', line 1081

def gsub_body #fix
  @txt=case @txt
  when /^\((i+|iv|v|vi+|ix|x|xi+)\)/
    @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>')
  when /^\(?(\d|[a-z])+\)/
    @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>')
  when /^\s*\d{1,3}\.\s/
    @txt.gsub(/^\s*(\d+\.)/,'<b>\1</b>')
  when /^\s*[A-Z]\.\s/
    @txt.gsub(/^\s*([A-Z]\.)/,'<b>\1</b>')
  else @txt
  end
end

#heading_bodyObject



992
993
994
# File 'lib/sisu/html_format.rb', line 992

def heading_body
  heading_normal('p','norm')
end

#heading_body0Object



995
996
997
# File 'lib/sisu/html_format.rb', line 995

def heading_body0
  heading_normal('h1','norm')
end

#heading_body1Object



998
999
1000
# File 'lib/sisu/html_format.rb', line 998

def heading_body1
  heading_normal('h1','norm')
end

#heading_body2Object



1001
1002
1003
# File 'lib/sisu/html_format.rb', line 1001

def heading_body2
  heading_normal('h2','norm')
end

#heading_body3Object



1004
1005
1006
# File 'lib/sisu/html_format.rb', line 1004

def heading_body3
  heading_normal('h3','norm')
end

#heading_body4Object



1007
1008
1009
# File 'lib/sisu/html_format.rb', line 1007

def heading_body4
  heading_normal('h4','norm')
end

#heading_body5Object



1010
1011
1012
# File 'lib/sisu/html_format.rb', line 1010

def heading_body5
  heading_normal('h5','norm')
end

#heading_body6Object



1013
1014
1015
# File 'lib/sisu/html_format.rb', line 1013

def heading_body6
  heading_normal('h6','norm')
end

#heading_body7Object



1016
1017
1018
# File 'lib/sisu/html_format.rb', line 1016

def heading_body7
  heading_normal('h7','norm')
end

#heading_normal(tag, attrib) ⇒ Object



979
980
981
982
983
984
985
986
987
988
989
990
991
# File 'lib/sisu/html_format.rb', line 979

def heading_normal(tag,attrib)
  section_break=(tag=~/h[1-5]/) \
  ? '<br><hr width=90% /><br>'
  : ''
  %{#{section_break}
<div class="substance">
  #{@p_num.ocn_display}
  <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name}
#{@named}#{@txt}
  </#{tag}>
</div>
}
end

#nametags_scroll(dob) ⇒ Object



869
870
871
872
873
874
875
876
877
878
879
# File 'lib/sisu/html_format.rb', line 869

def nametags_scroll(dob)
  tags=''
  if defined? dob.tags \
  and dob.tags.length > 0 # insert tags "hypertargets"
    dob.tags.each do |t|
      t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier
      tags=tags << %{<named id="#{t}" />}
    end
  end
  tags
end

#nametags_seg(dob) ⇒ Object

FIX



880
881
882
883
884
885
886
887
888
889
890
891
892
# File 'lib/sisu/html_format.rb', line 880

def nametags_seg(dob) #FIX
  tags=''
  if defined? dob.tags \
  and dob.tags.length > 0 # insert tags "hypertargets"
    dob.tags.compact.each do |t| # .compact hides a problem, nil should not occur fix (upstream)
      t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier
      tags=(t =~/^[0-9.]+$/) \
      ? tags             #check what can be sorted in ao
      : (tags << %{<a name="#{t}" ></a>})
    end
  end
  tags
end

#no_paranumObject



917
918
919
920
921
922
923
924
925
926
# File 'lib/sisu/html_format.rb', line 917

def no_paranum
  %{
<div class="substance">
  <label class="ocn">&nbsp;</label>
  <p class="norm">
#{@txt}
  </p>
</div>
}
end

#paraObject



941
942
943
# File 'lib/sisu/html_format.rb', line 941

def para
  para_form_css('p','norm')
end

#para_form_css(tag, attrib) ⇒ Object

regular paragraphs shaped here



927
928
929
930
931
932
933
934
935
936
937
938
939
940
# File 'lib/sisu/html_format.rb', line 927

def para_form_css(tag,attrib)                                                    # regular paragraphs shaped here
  ul=ulc=''
  if tag =~/li/
    ul,ulc="<ul>\n  ","\n  </ul>"
  end
  %{
<div class="substance">
  #{@p_num.ocn_display}
  #{ul}<#{tag} class="#{attrib}" #{@p_num.id}>
#{@named}#{@txt}
  </#{tag}>#{ulc}
</div>
}
end

#seg_heading4Object



1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
# File 'lib/sisu/html_format.rb', line 1057

def seg_heading4
  %{
<div class="substance">
  #{@p_num.ocn_display}
  <h1 class="norm" #{@p_num.id}>#{@p_num.name}
#{@txt}
  </h1>
</div>
}
end

#seg_heading5Object



1067
1068
1069
# File 'lib/sisu/html_format.rb', line 1067

def seg_heading5
  seg_heading_sub('p','bold')
end

#seg_heading6Object



1070
1071
1072
# File 'lib/sisu/html_format.rb', line 1070

def seg_heading6
  seg_heading_sub('p','bold')
end

#seg_heading_sub(tag, attrib) ⇒ Object



1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
# File 'lib/sisu/html_format.rb', line 1046

def seg_heading_sub(tag,attrib)
  @txt=@txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ')
  %{
<div class="substance">
  #{@p_num.ocn_display}
  <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headnamed}
#{@named}#{@txt}
  </#{tag}>
</div>
}
end

#table_css_endObject



1076
1077
1078
1079
1080
# File 'lib/sisu/html_format.rb', line 1076

def table_css_end
  '</table>
</p>
  </div>'
end

#title_heading(tag, attrib) ⇒ Object



1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
# File 'lib/sisu/html_format.rb', line 1019

def title_heading(tag,attrib)
  cl=(@make.build.html_minitoc?) \
  ? 'content'
  : 'content0'
  %{
<div class="#{cl}">
<#{tag} class="#{attrib}">
#{@named}#{@txt}
  </#{tag}>
</div>
}
end

#title_heading0Object



1031
1032
1033
# File 'lib/sisu/html_format.rb', line 1031

def title_heading0
  title_heading('h1','tiny')
end

#title_heading1Object



1034
1035
1036
# File 'lib/sisu/html_format.rb', line 1034

def title_heading1
  title_heading('h1','tiny')
end

#title_heading2Object



1037
1038
1039
# File 'lib/sisu/html_format.rb', line 1037

def title_heading2
  title_heading('h2','tiny')
end

#title_heading3Object



1040
1041
1042
# File 'lib/sisu/html_format.rb', line 1040

def title_heading3
  title_heading('h3','tiny')
end

#title_heading4Object



1043
1044
1045
# File 'lib/sisu/html_format.rb', line 1043

def title_heading4
  ''
end

#toc_head_copy_atObject



1111
1112
1113
# File 'lib/sisu/html_format.rb', line 1111

def toc_head_copy_at
  %{<p class="center">#{@txt}</p>\n}
end

#verseObject



953
954
955
# File 'lib/sisu/html_format.rb', line 953

def verse
  para_form_css('p','verse')
end