Class: SiSU_JSON_Format::FormatTextObject

Inherits:
Object
  • Object
show all
Includes:
SiSU_Parts_JSON
Defined in:
lib/sisu/json_format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SiSU_Parts_JSON

#the_line_break, #the_table_close, #the_url_decoration, #txt_close, #txt_open, #xml_close, #xml_open

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.



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
# 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

Instance Attribute Details

Returns the value of attribute banner.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def banner
  @banner
end

#dobObject

Returns the value of attribute dob.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def dob
  @dob
end

#format(tag, attrib) ⇒ Object

Returns the value of attribute format.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def format
  @format
end

#headnameObject

Returns the value of attribute headname.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def headname
  @headname
end

Returns the value of attribute link.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def link
  @link
end

#linknameObject

Returns the value of attribute linkname.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def linkname
  @linkname
end

#mdObject

Returns the value of attribute md.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def md
  @md
end

#ocnObject

Returns the value of attribute ocn.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def ocn
  @ocn
end

#p_numObject

Returns the value of attribute p_num.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def p_num
  @p_num
end

#paranumObject

Returns the value of attribute paranum.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def paranum
  @paranum
end

#tableObject

Returns the value of attribute table.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def table
  @table
end

#txtObject

Returns the value of attribute txt.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def txt
  @txt
end

#urlObject

Returns the value of attribute url.



311
312
313
# File 'lib/sisu/json_format.rb', line 311

def url
  @url
end

Instance Method Details

#boldObject



354
355
356
# File 'lib/sisu/json_format.rb', line 354

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

#bold_headerObject



454
455
456
457
458
459
460
461
462
463
# 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_paraObject



445
446
447
448
449
450
451
452
453
# 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

#bulletObject



357
358
359
# File 'lib/sisu/json_format.rb', line 357

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

#centerObject



351
352
353
# File 'lib/sisu/json_format.rb', line 351

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

#center_boldObject



473
474
475
# File 'lib/sisu/json_format.rb', line 473

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

#codeObject



348
349
350
# File 'lib/sisu/json_format.rb', line 348

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

#dlObject

check :trailer



421
422
423
# File 'lib/sisu/json_format.rb', line 421

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

#gsub_bodyObject



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# 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_bodyObject



373
374
375
# File 'lib/sisu/json_format.rb', line 373

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

#heading_body0Object



376
377
378
# File 'lib/sisu/json_format.rb', line 376

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

#heading_body1Object



379
380
381
# File 'lib/sisu/json_format.rb', line 379

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

#heading_body2Object



382
383
384
# File 'lib/sisu/json_format.rb', line 382

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

#heading_body3Object



385
386
387
# File 'lib/sisu/json_format.rb', line 385

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

#heading_body4Object



388
389
390
# File 'lib/sisu/json_format.rb', line 388

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

#heading_body5Object



391
392
393
# File 'lib/sisu/json_format.rb', line 391

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

#heading_body6Object



394
395
396
# File 'lib/sisu/json_format.rb', line 394

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

#heading_body7Object



397
398
399
# File 'lib/sisu/json_format.rb', line 397

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

#heading_normal(tag, attrib) ⇒ Object



363
364
365
366
367
368
369
370
371
372
# 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

#paraObject



345
346
347
# File 'lib/sisu/json_format.rb', line 345

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

#table_css_endObject

<!TZ!>



424
425
426
427
428
# File 'lib/sisu/json_format.rb', line 424

def table_css_end      #<!TZ!>
  '</table>
</p>
  </div>'
end

#title_header(tag, attrib) ⇒ Object



400
401
402
403
404
405
406
407
408
# File 'lib/sisu/json_format.rb', line 400

def title_header(tag,attrib)
  %{
<div class="content">
<#{tag} class="#{attrib}">
#{@txt}
  </#{tag}>
</div>
}
end

#title_header1Object



409
410
411
# File 'lib/sisu/json_format.rb', line 409

def title_header1
  title_header('h1','tiny')
end

#title_header2Object



412
413
414
# File 'lib/sisu/json_format.rb', line 412

def title_header2
  title_header('h2','tiny')
end

#title_header3Object



415
416
417
# File 'lib/sisu/json_format.rb', line 415

def title_header3
  title_header('h3','tiny')
end

#title_header4Object



418
419
420
# File 'lib/sisu/json_format.rb', line 418

def title_header4
  ''
end

#toc_head_copy_atObject



464
465
466
# File 'lib/sisu/json_format.rb', line 464

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