Class: SiSU_XHTML_EPUB2_Format::FormatTextObject
- Inherits:
-
Object
- Object
- SiSU_XHTML_EPUB2_Format::FormatTextObject
show all
- Includes:
- SiSU_Parts_XHTML
- Defined in:
- lib/sisu/xhtml_epub2_format.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#css, #home, #num_css, #paragraph_font_small, #paragraph_font_tiny, #set_fonts, #set_small, #set_tiny, #site, #the_font, #the_line_break, #the_margin, #the_nav, #the_table_close, #the_url, #the_url_decoration, #txt_0, #txt_1, #txt_2, #txt_3, #txt_close, #txt_concordance, #txt_manifest, #txt_open, #txt_toc_link, #xml_close, #xml_open
#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
Returns a new instance of FormatTextObject.
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1863
def initialize(md,t_o)
@md,@t_o=md,t_o
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
@target =t_o[:target] || nil if @format and not @format.empty?
if @format=~/^\d:(\S+)/ headname=$1 @headname=(headname =~/^[a-zA-Z]/) \
? %{<id="#{headname}">}
: %{<id="h#{headname}"></a>}
@headname=(headname =~/^[a-zA-Z]/) \
? %{<a name="#{headname}" id="#{headname}"></a>}
: %{<a name="h#{headname}" id="h#{headname}"></a>}
end
end
elsif t_o.class.inspect =~/Object/
@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 __FILE__ << ':' << __LINE__.to_s
p t_o.class
p caller
end
end
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
#banner ⇒ Object
Returns the value of attribute banner.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def banner
@banner
end
|
Returns the value of attribute format.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def format
@format
end
|
#headname ⇒ Object
Returns the value of attribute headname.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def headname
@headname
end
|
#link ⇒ Object
Returns the value of attribute link.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def link
@link
end
|
#linkname ⇒ Object
Returns the value of attribute linkname.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def linkname
@linkname
end
|
#md ⇒ Object
Returns the value of attribute md.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def md
@md
end
|
#ocn ⇒ Object
Returns the value of attribute ocn.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def ocn
@ocn
end
|
#p_num ⇒ Object
Returns the value of attribute p_num.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def p_num
@p_num
end
|
#paranum ⇒ Object
Returns the value of attribute paranum.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def paranum
@paranum
end
|
#t_o ⇒ Object
Returns the value of attribute t_o.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def t_o
@t_o
end
|
#table ⇒ Object
Returns the value of attribute table.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def table
@table
end
|
#txt ⇒ Object
Returns the value of attribute txt.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def txt
@txt
end
|
#url ⇒ Object
Returns the value of attribute url.
1862
1863
1864
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1862
def url
@url
end
|
Instance Method Details
#alt ⇒ Object
1961
1962
1963
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1961
def alt
para_form_css('p','alt',@txt)
end
|
#block ⇒ Object
1958
1959
1960
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1958
def block
para_form_css('p','block',@txt)
end
|
#bold ⇒ Object
1973
1974
1975
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1973
def bold
para_form_css('p','bold',@txt)
end
|
#bold_heading ⇒ Object
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2089
def bold_heading @txt=@txt.gsub(/[1-9]~\S+/,'').
gsub(/[1-9]~/,'')
%{<p class="bold">
#{@txt}
</p>
#{the_margin.num_css}
#{$ep[:hsp]*3}
#{the_table_close}}
end
|
#bold_para ⇒ Object
2080
2081
2082
2083
2084
2085
2086
2087
2088
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2080
def bold_para
%{#{the_margin.txt_0}
<p class="bold">
#{@txt}
</p>
#{the_margin.num_css}
#{$ep[:hsp]*3}
#{the_table_close}}
end
|
#break ⇒ Object
1987
1988
1989
1990
1991
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1987
def break
@txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}|#{Mx[:br_page_line]}/,'<hr /><br />').
gsub(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />')
para_form_css('p','norm',@txt)
end
|
#bullet ⇒ Object
1976
1977
1978
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1976
def bullet
para_form_css('li','bullet',@txt)
end
|
#center ⇒ Object
1970
1971
1972
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1970
def center
para_form_css('p','center',@txt)
end
|
#center_bold ⇒ Object
2111
2112
2113
2114
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2111
def center_bold
@txt=SanitizeXML.xml(@txt)
%{<p class="centerbold">#{@txt}</p>\n}
end
|
#code ⇒ Object
1967
1968
1969
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1967
def code
para_form_css('p','code',@txt)
end
|
#dl ⇒ Object
2057
2058
2059
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2057
def dl "<dl><b>#{@txt}</b> #{@trailer}</dl>"
end
|
#endnote_body ⇒ Object
1916
1917
1918
1919
1920
1921
1922
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1916
def endnote_body
%{
<p class="endnote">
#{@txt}
</p>
}
end
|
#endnote_body_indent ⇒ Object
1923
1924
1925
1926
1927
1928
1929
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1923
def endnote_body_indent
%{
<p class="endnote_indent">
#{@txt}
</p>
}
end
|
#group ⇒ Object
1955
1956
1957
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1955
def group
para_form_css('p','group',@txt)
end
|
#gsub_body ⇒ Object
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2065
def gsub_body @txt=case @txt
when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\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 /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\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
|
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1906
def nametags_seg(dob) tags=''
if defined? dob.tags \
and dob.tags.length > 0 dob.tags.each do |t|
tags=tags << %{<a name="#{t}" />}
end
end
tags
end
|
#no_paranum ⇒ Object
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1930
def no_paranum
%{
<div class="substance">
<label class="ocn">#{$ep[:hsp]}</label>
<p class="norm">
#{@txt}
</p>
</div>
}
end
|
#para ⇒ Object
1952
1953
1954
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1952
def para
para_form_css('p','norm',@txt)
end
|
regular paragraphs shaped here
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1940
def para_form_css(tag,attrib,txt) ul=ulc=''
ul,ulc="<ul>\n ","\n </ul>" if @tag =~/li/
%{
<div class="substance">
#{@p_num.ocn_display}
#{ul}<#{tag} class="#{attrib}" #{@p_num.id}>
#{@named}#{txt}
</#{tag}>#{ulc}
</div>
}
end
|
#seg_heading4 ⇒ Object
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2038
def seg_heading4
%{
<div class="substance">
#{@p_num.ocn_display}
<h1 class="norm" #{@p_num.id}>
#{@txt}
</h1>
</div>
}
end
|
#seg_heading5 ⇒ Object
2048
2049
2050
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2048
def seg_heading5
seg_heading_sub('p','bold',@txt)
end
|
#seg_heading6 ⇒ Object
2051
2052
2053
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2051
def seg_heading6
seg_heading_sub('p','bold',@txt)
end
|
#seg_heading7 ⇒ Object
2054
2055
2056
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2054
def seg_heading7
seg_heading_sub('p','bold',@txt)
end
|
#seg_heading_sub(tag, attrib, txt) ⇒ Object
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2027
def seg_heading_sub(tag,attrib,txt)
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}
#{@named}#{@txt}
</#{tag}>
</div>
}
end
|
#table_css_end ⇒ Object
2060
2061
2062
2063
2064
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2060
def table_css_end
'</table>
</p>
</div>'
end
|
#title_heading(tag, attrib) ⇒ Object
1995
1996
1997
1998
1999
2000
2001
2002
2003
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1995
def title_heading(tag,attrib)
%{
<div class="content">
<#{tag} class="#{attrib}">
#{@named}#{@txt}
</#{tag}>
</div>
}
end
|
#title_heading0 ⇒ Object
2004
2005
2006
2007
2008
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2004
def title_heading0
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h1','tiny')
end
|
#title_heading1 ⇒ Object
2009
2010
2011
2012
2013
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2009
def title_heading1
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h1','tiny')
end
|
#title_heading2 ⇒ Object
2014
2015
2016
2017
2018
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2014
def title_heading2
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h2','tiny')
end
|
#title_heading3 ⇒ Object
2019
2020
2021
2022
2023
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2019
def title_heading3
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h3','tiny')
end
|
#title_heading4 ⇒ Object
2024
2025
2026
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2024
def title_heading4
''
end
|
#toc_head_copy_at ⇒ Object
2099
2100
2101
2102
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2099
def toc_head_copy_at
@txt=SanitizeXML.xml(@txt)
%{<p class="center">#{@txt}</p>\n}
end
|
#verse ⇒ Object
1964
1965
1966
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1964
def verse
para_form_css('p','verse',@txt)
end
|