Class: SiSU_HTML_Tune::Tune
Instance Method Summary
collapse
#_url_path_image_base, #band1, #band2, #banner_band, #black, #blue_ink, #blue_tinge, #css, #grey, #grey_medium, #grey_pale, #home_button_only, #ico, #instrument_cover_band_scr, #instrument_cover_band_seg, #num, #num_css, #numless, #paragraph_font_small, #paragraph_font_tiny, #png_home, #png_home_button, #set_color, #set_face, #set_fonts, #set_size_endnote, #set_small, #set_tiny, #table1, #table2, #table_txt, #table_txt_r, #the_banner, #the_color, #the_font, #the_line_break, #the_margin, #the_nav, #the_png, #the_table_cellpad_box, #the_table_close, #the_url_decoration, #the_width, #txt_0, #txt_1, #txt_2, #txt_3, #txt_close, #txt_concordance, #txt_doc_link, #txt_homepage, #txt_manifest, #txt_open, #txt_toc_link, #white, #xml_close, #xml_open, #yellow_light
#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(data, md) ⇒ Tune
Returns a new instance of Tune.
Instance Method Details
#amp_angle_brackets(dob) ⇒ Object
247
248
249
250
251
252
253
|
# File 'lib/sisu/html_tune.rb', line 247
def amp_angle_brackets(dob)
dob.obj=dob.obj.
gsub(/&/u,'&').
gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}").
gsub(/</u,'<').gsub(/>/u,'>')
dob
end
|
#endnotes_html(dob) ⇒ Object
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/sisu/html_tune.rb', line 254
def endnotes_html(dob)
unless dob.is ==:code
dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,
%{ <a href="##{Mx[:note]}\\2"><note id="#{Mx[:note_ref]}\\2"> <sup>\\2</sup> </note></a> } +
%{\\1\\2 <a href="##{Mx[:note_ref]}\\2"><note id="#{Mx[:note]}\\2"> <sup>\\2.</sup></note></a> \\3 \\4}).
gsub(/(#{Mx[:en_b_o]})([*+]\d+)\s+(.+?)(#{Mx[:en_b_c]})/,
%{ <a href="##{Mx[:note]}\\2"><note id="#{Mx[:note_ref]}\\2"> <sup>\\2</sup> </note></a> } +
%{\\1\\2 <a href="##{Mx[:note_ref]}\\2"><note id="#{Mx[:note]}\\2"> <sup>\\2.</sup></note></a> \\3 \\4}).
gsub(/(#{Mx[:en_a_o]})([*+]+)\s+(.+?)(#{Mx[:en_a_c]})/,
%{ <a href="##{Mx[:note]}\\2"><note id="#{Mx[:note_ref]}\\2"> <sup>\\2</sup> </note></a> } +
%{\\1\\2 <a href="##{Mx[:note_ref]}\\2"><note id="#{Mx[:note]}\\2"> <sup>\\2</sup></note></a> \\3 \\4})
end
dob
end
|
#markup(dob) ⇒ Object
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'lib/sisu/html_tune.rb', line 268
def markup(dob)
dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br>') unless dob.is==:table
dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>').
gsub(/#{Mx[:gl_bullet]}/m,'● ').
gsub(/#{Mx[:nbsp]}/,' ').
gsub(/<(p|br) \/>/,'<\1>')
dob=SiSU_HTML_Tune::CleanHTML.new(dob).clean
dob
end
|
#output ⇒ Object
288
289
290
291
292
293
294
295
296
|
# File 'lib/sisu/html_tune.rb', line 288
def output
data=@data
@tuned_file=data.each.map do |dob|
dob.obj=dob.obj.strip.chomp
dob
end
@tuned_file << "\n<EOF>" if (@md.fns =~/\.sst0/) @tuned_file
end
|
#songsheet_array(data) ⇒ Object
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/sisu/html_tune.rb', line 150
def songsheet_array(data)
data_tuned=[]
data.each do |dob|
dob=amp_angle_brackets(dob)
dob=endnotes_html(dob)
dob=url_markup(dob)
dob=markup(dob)
data_tuned << dob
end
data_tuned
end
|
#url_markup(dob) ⇒ Object
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
# File 'lib/sisu/html_tune.rb', line 209
def url_markup(dob)
unless dob.is==:code
if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/
@word_mode=dob.obj.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)[()\[\]]*[,.;:!?'"]{0,2}|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|[^#{Mx[:lnk_o]}#{Mx[:lnk_c]}]+/mu)
words=urls(@word_mode)
dob.obj=dob.obj.gsub(/.+/m,words)
end dob.obj=dob.obj.gsub(/\\copyright/i,%{<sup>©</sup>})
if (dob.obj !~/\<:ad\s+\.\.\//)
dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/,
%{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n})
else
dob.obj=dob.obj.gsub(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/,
%{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n})
end
dob.obj=dob.obj.gsub(/!pick/,%{<img border="0" height="15" width="15" src="#{@env.url.images}/#{the_icon.i_choice}" alt="stellar">}).
gsub(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{the_icon.i_new}" alt="new">}).
gsub(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>').
gsub(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ').
gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>'). gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{the_url_decoration.xml_open}<a href="mailto:\\1">\\1</a>#{the_url_decoration.xml_close}}).
gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{the_url_decoration.xml_open}<a href="\\1" target="_top">\\1</a>#{the_url_decoration.xml_close}}) if dob.obj =~/#{Xx[:html_relative2]}\/\S+/ \
and dob.obj !~/(\"#{Xx[:html_relative2]}\/\S+?\"|>\s*#{Xx[:html_relative2]}\/\S+<)/
dob.obj=dob.obj.gsub(/(#{Xx[:html_relative2]}\/\S+)/,'<a href="\1">\1</a>')
end
if dob.obj =~/..\/\S+/ \
and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/
dob.obj=dob.obj.gsub(/\.\.(\/\S+)/,%{<a href="#{Xx[:html_relative2]}\1">\1</a>})
end
dob.obj=dob.obj.gsub(/<a href=":/,%{<a href="#{the_url.site}/}).
gsub(/<a href="\.\.\//,%{<a href="#{the_url.site}/}).
gsub(/<a href="#{Xx[:html_relative2]}\//,%{<a href="#{the_url.site}/})
else
dob.obj=dob.obj.gsub(/</m,'<').gsub(/>/m,'>')
end
dob
end
|
#urls(data) ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/sisu/html_tune.rb', line 161
def urls(data)
@words=data.each.map do |word|
if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/
http_=true
if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/.match(word).captures
elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}:\S+?#{Mx[:rel_c]}/
m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/.match(word).captures
u="#{Xx[:html_relative2]}/" + u
elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
http_=false
m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/.match(word).captures
elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image/
m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(image)/.match(word).captures
end
case m
when /\.png|\.jpg|\.gif|c=|\s\d+x\d+/
w,h=/\s(\d+)x(\d+)/.match(m).captures if m =~/\s\d+x\d+/
w=%{width="#{w}"} if w
h=%{height="#{h}"} if h
c=m[/"(.+?)"/m,1]
caption=%{<br><p class="caption">#{c}</p>} if c
png=m.scan(/\S+/)[0]
image_path=@md.file.output_path.html_seg.rel_image
ins=if u \
and u.strip !~/^image$/
%{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{caption}}
else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0">#{caption}}
end
word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins)
else
link=m[/(.+)/m]
png=m.scan(/\S+/)[0].strip
link=link.strip
u=u.gsub(/(\S+)/,"#{Xx[:segment]}#\\1") if u !~/\// unless http_ ins=%{<a href="#{u}">#{link}</a>}
word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins).
gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins)
end
word
else word
end
end.join(' ')
end
|