class SiSU_HTML_Format::FormatTextObject

Attributes

banner[RW]
format[RW]
headname[RW]
linkname[RW]
md[RW]
ocn[RW]
p_num[RW]
paranum[RW]
t_o[RW]
table[RW]
txt[RW]
url[RW]

Public Class Methods

new(md,t_o) click to toggle source
# 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

Public Instance Methods

alt() click to toggle source
# File lib/sisu/html_format.rb, line 950
def alt
  para_form_css('p','alt')
end
block() click to toggle source
# File lib/sisu/html_format.rb, line 944
def block
  para_form_css('p','block')
end
bold() click to toggle source
# File lib/sisu/html_format.rb, line 962
def bold
  para_form_css('p','bold')
end
bold_heading() click to toggle source
# 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_para() click to toggle source
# 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
bullet() click to toggle source
# File lib/sisu/html_format.rb, line 965
def bullet
  para_form_css('li','bullet')
end
center() click to toggle source
# File lib/sisu/html_format.rb, line 959
def center
  para_form_css('p','center')
end
center_bold() click to toggle source
# File lib/sisu/html_format.rb, line 1120
def center_bold
  %{<p class="centerbold">#{@txt}</p>\n}
end
code() click to toggle source
# File lib/sisu/html_format.rb, line 956
def code
  para_form_css('p','code')
end
dl() click to toggle source
# File lib/sisu/html_format.rb, line 1073
def dl #check :trailer
  "<dl><b>#{@txt}</b> #{@trailer}</dl>"
end
endnote_body() click to toggle source
# File lib/sisu/html_format.rb, line 903
    def endnote_body
      %{
<p class="endnote">
  #{@txt}
</p>
}
    end
endnote_body_indent() click to toggle source
# File lib/sisu/html_format.rb, line 910
    def endnote_body_indent
      %{
  <p class="endnote_indent">
    #{@txt}
  </p>
}
    end
group() click to toggle source
# File lib/sisu/html_format.rb, line 947
def group
  para_form_css('p','group')
end
gsub_body() click to toggle source
# 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_body() click to toggle source
# File lib/sisu/html_format.rb, line 992
def heading_body
  heading_normal('p','norm')
end
heading_body0() click to toggle source
# File lib/sisu/html_format.rb, line 995
def heading_body0
  heading_normal('h1','norm')
end
heading_body1() click to toggle source
# File lib/sisu/html_format.rb, line 998
def heading_body1
  heading_normal('h1','norm')
end
heading_body2() click to toggle source
# File lib/sisu/html_format.rb, line 1001
def heading_body2
  heading_normal('h2','norm')
end
heading_body3() click to toggle source
# File lib/sisu/html_format.rb, line 1004
def heading_body3
  heading_normal('h3','norm')
end
heading_body4() click to toggle source
# File lib/sisu/html_format.rb, line 1007
def heading_body4
  heading_normal('h4','norm')
end
heading_body5() click to toggle source
# File lib/sisu/html_format.rb, line 1010
def heading_body5
  heading_normal('h5','norm')
end
heading_body6() click to toggle source
# File lib/sisu/html_format.rb, line 1013
def heading_body6
  heading_normal('h6','norm')
end
heading_body7() click to toggle source
# File lib/sisu/html_format.rb, line 1016
def heading_body7
  heading_normal('h7','norm')
end
heading_normal(tag,attrib) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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_paranum() click to toggle source
# 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
para() click to toggle source
# File lib/sisu/html_format.rb, line 941
def para
  para_form_css('p','norm')
end
para_form_css(tag,attrib) click to toggle source
# 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_heading4() click to toggle source
# 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_heading5() click to toggle source
# File lib/sisu/html_format.rb, line 1067
def seg_heading5
  seg_heading_sub('p','bold')
end
seg_heading6() click to toggle source
# File lib/sisu/html_format.rb, line 1070
def seg_heading6
  seg_heading_sub('p','bold')
end
seg_heading_sub(tag,attrib) click to toggle source
# 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_end() click to toggle source
# File lib/sisu/html_format.rb, line 1076
  def table_css_end
    '</table>
  </p>
</div>'
  end
title_heading(tag,attrib) click to toggle source
# 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_heading0() click to toggle source
# File lib/sisu/html_format.rb, line 1031
def title_heading0
  title_heading('h1','tiny')
end
title_heading1() click to toggle source
# File lib/sisu/html_format.rb, line 1034
def title_heading1
  title_heading('h1','tiny')
end
title_heading2() click to toggle source
# File lib/sisu/html_format.rb, line 1037
def title_heading2
  title_heading('h2','tiny')
end
title_heading3() click to toggle source
# File lib/sisu/html_format.rb, line 1040
def title_heading3
  title_heading('h3','tiny')
end
title_heading4() click to toggle source
# File lib/sisu/html_format.rb, line 1043
def title_heading4
  ''
end
toc_head_copy_at() click to toggle source
# File lib/sisu/html_format.rb, line 1111
def toc_head_copy_at
  %{<p class="center">#{@txt}</p>\n}
end
verse() click to toggle source
# File lib/sisu/html_format.rb, line 953
def verse
  para_form_css('p','verse')
end