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.



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

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.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def banner
  @banner
end

#format(tag, attrib) ⇒ Object

Returns the value of attribute format.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def format
  @format
end

#headnameObject

check whether used



895
896
897
# File 'lib/sisu/html_format.rb', line 895

def headname
  @headname
end

Returns the value of attribute link.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def link
  @link
end

#linknameObject

Returns the value of attribute linkname.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def linkname
  @linkname
end

#mdObject

Returns the value of attribute md.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def md
  @md
end

#ocnObject

Returns the value of attribute ocn.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def ocn
  @ocn
end

#p_numObject

Returns the value of attribute p_num.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def p_num
  @p_num
end

#paranumObject

Returns the value of attribute paranum.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def paranum
  @paranum
end

#t_oObject

Returns the value of attribute t_o.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def t_o
  @t_o
end

#tableObject

Returns the value of attribute table.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def table
  @table
end

#txtObject

Returns the value of attribute txt.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def txt
  @txt
end

#urlObject

Returns the value of attribute url.



838
839
840
# File 'lib/sisu/html_format.rb', line 838

def url
  @url
end

Instance Method Details

#altObject



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

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

#blockObject



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

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

#boldObject



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

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

#bold_headingObject



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

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

#bold_paraObject



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

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

#bulletObject



967
968
969
# File 'lib/sisu/html_format.rb', line 967

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

#centerObject



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

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

#center_boldObject



1122
1123
1124
# File 'lib/sisu/html_format.rb', line 1122

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

#codeObject



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

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

#dlObject

check :trailer



1075
1076
1077
# File 'lib/sisu/html_format.rb', line 1075

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

#endnote_bodyObject



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

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

#endnote_body_indentObject



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

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

#groupObject



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

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

#gsub_bodyObject

fix



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

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



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

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

#heading_body0Object



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

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

#heading_body1Object



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

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

#heading_body2Object



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

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

#heading_body3Object



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

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

#heading_body4Object



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

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

#heading_body5Object



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

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

#heading_body6Object



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

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

#heading_body7Object



1018
1019
1020
# File 'lib/sisu/html_format.rb', line 1018

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

#heading_normal(tag, attrib) ⇒ Object



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

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



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

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



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

def nametags_seg(dob) #FIX
  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=(t =~/^[0-9.]+$/) \
      ? tags             #check what can be sorted in ao
      : (tags << %{<a name="#{t}" ></a>})
    end
  end
  tags
end

#no_paranumObject



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

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

#paraObject



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

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

#para_form_css(tag, attrib) ⇒ Object

regular paragraphs shaped here



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

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



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

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



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

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

#seg_heading6Object



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

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

#seg_heading_sub(tag, attrib) ⇒ Object



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

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



1078
1079
1080
1081
1082
# File 'lib/sisu/html_format.rb', line 1078

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

#title_heading(tag, attrib) ⇒ Object



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

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



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

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

#title_heading1Object



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

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

#title_heading2Object



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

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

#title_heading3Object



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

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

#title_heading4Object



1045
1046
1047
# File 'lib/sisu/html_format.rb', line 1045

def title_heading4
  ''
end

#toc_head_copy_atObject



1113
1114
1115
# File 'lib/sisu/html_format.rb', line 1113

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

#verseObject



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

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