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.
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
1906
1907
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1865
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.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def banner
@banner
end
|
Returns the value of attribute format.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def format
@format
end
|
#headname ⇒ Object
Returns the value of attribute headname.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def headname
@headname
end
|
#link ⇒ Object
Returns the value of attribute link.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def link
@link
end
|
#linkname ⇒ Object
Returns the value of attribute linkname.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def linkname
@linkname
end
|
#md ⇒ Object
Returns the value of attribute md.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def md
@md
end
|
#ocn ⇒ Object
Returns the value of attribute ocn.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def ocn
@ocn
end
|
#p_num ⇒ Object
Returns the value of attribute p_num.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def p_num
@p_num
end
|
#paranum ⇒ Object
Returns the value of attribute paranum.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def paranum
@paranum
end
|
#t_o ⇒ Object
Returns the value of attribute t_o.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def t_o
@t_o
end
|
#table ⇒ Object
Returns the value of attribute table.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def table
@table
end
|
#txt ⇒ Object
Returns the value of attribute txt.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def txt
@txt
end
|
#url ⇒ Object
Returns the value of attribute url.
1864
1865
1866
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1864
def url
@url
end
|
Instance Method Details
#alt ⇒ Object
1963
1964
1965
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1963
def alt
para_form_css('p','alt',@txt)
end
|
#block ⇒ Object
1960
1961
1962
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1960
def block
para_form_css('p','block',@txt)
end
|
#bold ⇒ Object
1975
1976
1977
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1975
def bold
para_form_css('p','bold',@txt)
end
|
#bold_heading ⇒ Object
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2091
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
2082
2083
2084
2085
2086
2087
2088
2089
2090
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2082
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
1989
1990
1991
1992
1993
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1989
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
1978
1979
1980
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1978
def bullet
para_form_css('li','bullet',@txt)
end
|
#center ⇒ Object
1972
1973
1974
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1972
def center
para_form_css('p','center',@txt)
end
|
#center_bold ⇒ Object
2113
2114
2115
2116
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2113
def center_bold
@txt=SanitizeXML.xml(@txt)
%{<p class="centerbold">#{@txt}</p>\n}
end
|
#code ⇒ Object
1969
1970
1971
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1969
def code
para_form_css('p','code',@txt)
end
|
#dl ⇒ Object
2059
2060
2061
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2059
def dl "<dl><b>#{@txt}</b> #{@trailer}</dl>"
end
|
#endnote_body ⇒ Object
1918
1919
1920
1921
1922
1923
1924
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1918
def endnote_body
%{
<p class="endnote">
#{@txt}
</p>
}
end
|
#endnote_body_indent ⇒ Object
1925
1926
1927
1928
1929
1930
1931
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1925
def endnote_body_indent
%{
<p class="endnote_indent">
#{@txt}
</p>
}
end
|
#group ⇒ Object
1957
1958
1959
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1957
def group
para_form_css('p','group',@txt)
end
|
#gsub_body ⇒ Object
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2067
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
|
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1908
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
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1932
def no_paranum
%{
<div class="substance">
<label class="ocn">#{$ep[:hsp]}</label>
<p class="norm">
#{@txt}
</p>
</div>
}
end
|
#para ⇒ Object
1954
1955
1956
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1954
def para
para_form_css('p','norm',@txt)
end
|
regular paragraphs shaped here
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1942
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
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2040
def seg_heading4
%{
<div class="substance">
#{@p_num.ocn_display}
<h1 class="norm" #{@p_num.id}>
#{@txt}
</h1>
</div>
}
end
|
#seg_heading5 ⇒ Object
2050
2051
2052
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2050
def seg_heading5
seg_heading_sub('p','bold',@txt)
end
|
#seg_heading6 ⇒ Object
2053
2054
2055
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2053
def seg_heading6
seg_heading_sub('p','bold',@txt)
end
|
#seg_heading7 ⇒ Object
2056
2057
2058
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2056
def seg_heading7
seg_heading_sub('p','bold',@txt)
end
|
#seg_heading_sub(tag, attrib, txt) ⇒ Object
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2029
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
2062
2063
2064
2065
2066
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2062
def table_css_end
'</table>
</p>
</div>'
end
|
#title_heading(tag, attrib) ⇒ Object
1997
1998
1999
2000
2001
2002
2003
2004
2005
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1997
def title_heading(tag,attrib)
%{
<div class="content">
<#{tag} class="#{attrib}">
#{@named}#{@txt}
</#{tag}>
</div>
}
end
|
#title_heading0 ⇒ Object
2006
2007
2008
2009
2010
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2006
def title_heading0
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h1','tiny')
end
|
#title_heading1 ⇒ Object
2011
2012
2013
2014
2015
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2011
def title_heading1
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h1','tiny')
end
|
#title_heading2 ⇒ Object
2016
2017
2018
2019
2020
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2016
def title_heading2
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h2','tiny')
end
|
#title_heading3 ⇒ Object
2021
2022
2023
2024
2025
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2021
def title_heading3
DISABLE[:epub][:per_section_title] \
? ''
: title_heading('h3','tiny')
end
|
#title_heading4 ⇒ Object
2026
2027
2028
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2026
def title_heading4
''
end
|
#toc_head_copy_at ⇒ Object
2101
2102
2103
2104
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 2101
def toc_head_copy_at
@txt=SanitizeXML.xml(@txt)
%{<p class="center">#{@txt}</p>\n}
end
|
#verse ⇒ Object
1966
1967
1968
|
# File 'lib/sisu/xhtml_epub2_format.rb', line 1966
def verse
para_form_css('p','verse',@txt)
end
|