class SiSU_JSON_Format::FormatTextObject

Attributes

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

Public Class Methods

new(md,t_o) click to toggle source
# File lib/sisu/json_format.rb, line 312
def initialize(md,t_o)
  @md,@t_o=md,t_o
  if t_o.class.inspect =~/Object/
    @txt=if defined? t_o.obj; t_o.obj
    else nil
    end
    @ocn=if defined? t_o.ocn; t_o.ocn.to_s
    else nil
    end
    @headname=if t_o.is==:heading and defined? t_o.name; t_o.name
    else nil
    end
  else
    if @md.opt.act[:maintenance][:set]==:on
      p __FILE__ << ':' << __LINE__.to_s
      p t_o.class
      p caller
    end
  end
  if defined? @t_o.ocn
    ocn=((@t_o.ocn.to_s =~/\d+/) ? @t_o.ocn : nil)
    @p_num=ParagraphNumber.new(@md,ocn)
  end
  if @format and not @format.empty?
    if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/
      headname=$1 #format[/\d~(\S+)/m,1]
      @headname=if headname =~/^[a-zA-Z]/; %{<a name="#{headname}" id="#{headname}"></a>} #consider: h_#{headname}
      else %{<a name="h#{headname}" id="h#{headname}"></a>}
      end
    end
  end
  @dob=t_o if defined? t_o.is
end

Public Instance Methods

bold() click to toggle source
# File lib/sisu/json_format.rb, line 354
def bold
  para_form_css('p','bold')
end
bold_header() click to toggle source
# File lib/sisu/json_format.rb, line 454
    def bold_header
      @txt=@txt.gsub(/[1-9]~(\S+)/,'<a name="\1"></a>').
        gsub(/[1-9]~/,'')
      %{<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/json_format.rb, line 445
    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/json_format.rb, line 357
def bullet
  para_form_css('li','bullet')
end
center() click to toggle source
# File lib/sisu/json_format.rb, line 351
def center
  para_form_css('p','center')
end
center_bold() click to toggle source
# File lib/sisu/json_format.rb, line 473
def center_bold
  %{<p class="centerbold">#{@txt}</p>\n}
end
code() click to toggle source
# File lib/sisu/json_format.rb, line 348
def code
  para_form_css('p','code')
end
dl() click to toggle source
# File lib/sisu/json_format.rb, line 421
def dl #check :trailer
  "<dl><b>#{@txt}</b> #{@trailer}</dl>"
end
gsub_body() click to toggle source
# File lib/sisu/json_format.rb, line 429
    def gsub_body
#fix
      @txt=case @txt
      when /^\s*\((i+|iv|v|vi+|ix|x|xi+)\)/
        @txt.gsub(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'<b>(\1)</b>').
          gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1<b>(\2)</b>')
      when /^\s*\(?(\d|[a-z])+\)/
        @txt.gsub(/^\((\d+|[a-z])+\)/,'<b>(\1)</b>').
          gsub(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1<b>(\2)</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/json_format.rb, line 373
def heading_body
  heading_normal('p','norm')
end
heading_body0() click to toggle source
# File lib/sisu/json_format.rb, line 376
def heading_body0
  heading_normal('h1','norm')
end
heading_body1() click to toggle source
# File lib/sisu/json_format.rb, line 379
def heading_body1
  heading_normal('h1','norm')
end
heading_body2() click to toggle source
# File lib/sisu/json_format.rb, line 382
def heading_body2
  heading_normal('h2','norm')
end
heading_body3() click to toggle source
# File lib/sisu/json_format.rb, line 385
def heading_body3
  heading_normal('h3','norm')
end
heading_body4() click to toggle source
# File lib/sisu/json_format.rb, line 388
def heading_body4
  heading_normal('h4','norm')
end
heading_body5() click to toggle source
# File lib/sisu/json_format.rb, line 391
def heading_body5
  heading_normal('h5','norm')
end
heading_body6() click to toggle source
# File lib/sisu/json_format.rb, line 394
def heading_body6
  heading_normal('h6','norm')
end
heading_body7() click to toggle source
# File lib/sisu/json_format.rb, line 397
def heading_body7
  heading_normal('h7','norm')
end
heading_normal(tag,attrib) click to toggle source
# File lib/sisu/json_format.rb, line 363
    def heading_normal(tag,attrib)
      %{
<div class="substance">
  #{@p_num.ocn_display}
  <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name}
    #{@headname}#{@txt}
  </#{tag}>
</div>
}
    end
para() click to toggle source
# File lib/sisu/json_format.rb, line 345
def para
  para_form_css('p','norm')
end
table_css_end() click to toggle source
# File lib/sisu/json_format.rb, line 424
  def table_css_end      #<!TZ!>
    '</table>
  </p>
</div>'
  end
title_header(tag,attrib) click to toggle source
# File lib/sisu/json_format.rb, line 400
    def title_header(tag,attrib)
      %{
<div class="content">
<#{tag} class="#{attrib}">
    #{@txt}
  </#{tag}>
</div>
}
    end
title_header1() click to toggle source
# File lib/sisu/json_format.rb, line 409
def title_header1
  title_header('h1','tiny')
end
title_header2() click to toggle source
# File lib/sisu/json_format.rb, line 412
def title_header2
  title_header('h2','tiny')
end
title_header3() click to toggle source
# File lib/sisu/json_format.rb, line 415
def title_header3
  title_header('h3','tiny')
end
title_header4() click to toggle source
# File lib/sisu/json_format.rb, line 418
def title_header4
  ''
end
toc_head_copy_at() click to toggle source
# File lib/sisu/json_format.rb, line 464
def toc_head_copy_at
  %{<p class="center">#{@txt}</p>\n}
end