aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/html_tune.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2008-07-22 20:00:59 -0400
committerRalph Amissah <ralph@amissah.com>2008-07-22 20:00:59 -0400
commitd29a3e5469d8468084641c385ebf16948f7c2437 (patch)
tree1a2306de3c5c1055dbc0374b95f31c335f5da85c /lib/sisu/v0/html_tune.rb
parentaction response query fix (diff)
sisu-0.68.0 proposed
* middle layer document representation changed, (accounting for substantial patch) * texpdf multiple document sizes as specified in config * numerous small fixes [should on the whole be easier to maintain]
Diffstat (limited to 'lib/sisu/v0/html_tune.rb')
-rw-r--r--lib/sisu/v0/html_tune.rb56
1 files changed, 31 insertions, 25 deletions
diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb
index 8cd8841e..11976af9 100644
--- a/lib/sisu/v0/html_tune.rb
+++ b/lib/sisu/v0/html_tune.rb
@@ -101,6 +101,8 @@ module SiSU_Tune
@html=html
end
def clean
+ @html.gsub!(/#{Mx[:gl_o]}(#[0-9]+)#{Mx[:gl_c]}/u,'&\1;')
+ @html.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;')
@html.gsub!(/¢/u,'&cent;') # &#162;
@html.gsub!(/£/u,'&pound;') # &#163;
@html.gsub!(/¥/u,'&yen;') # &#165;
@@ -208,9 +210,7 @@ module SiSU_Tune
tell.txt_grey unless @md.cmd =~/q/
data=Tune.new(@data,@md).endnotes_html
data=Tune.new(data,@md).url_markup
- if @sys.locale =~/utf-?8/i
- data=Tune.new(data,@md).utf8_markup
- end
+ data=Tune.new(data,@md).markup
if @md.cmd =~/M/ #Hard Output Tune Optional on/off here
data=Output.new(data,@md).hard_output
Output.new(data,@md).marshal
@@ -224,22 +224,30 @@ module SiSU_Tune
data=@data
@tuned_file=[]
data.each do |para|
- para.gsub!(/(\d~(\S+))/,'\1<a name="H#\2">#\2.</a>&nbsp;')
+ para.gsub!(/#{Mx[:lv_o]}\d:(\S?)#{Mx[:lv_c]}/,'\0<a name="H#\1">#\1.</a>&nbsp;')
@tuned_file << para
end
end
- def utf8_markup
+ def markup
@tuned_file=[]
@data.each do |para|
#@utf8.new(para).html
#@utf8.html(@para)
- if @sys.locale =~/utf-?8/i # instead ucs for utf8 #require 'iconv' ? Iñtërnâtiônàlizætiøn
- #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü
- #¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷
- ##para.gsub!(//, '&#;')
- ##para.gsub!(//, '&;')
- para=SiSU_Tune::Clean_html.new(para).clean
- end
+ para.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;')
+ para.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
+ para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />')
+ para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'<p><hr width=90% /></p>') # else clean ''
+ para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>')
+ para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>')
+ para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>')
+ para.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>')
+ para.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>')
+ para.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>')
+ para.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>')
+ para.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>')
+ para.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>')
+ para.gsub!(/<(p|br)>/,'<\1 />')
+ para=SiSU_Tune::Clean_html.new(para).clean
@tuned_file << para
end
end
@@ -287,12 +295,10 @@ module SiSU_Tune
data=@data
@tuned_file=[]
data.each do |para|
- para.gsub!(/<:name\#(\S+?)>/,'<a name="\1"></a>')
+ #para.gsub!(/#{Mx[:mk_o]}name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>')
para.gsub!(/<-#>/,'')
- para.gsub!(/<:p[bn]>/,'')
- para.gsub!(/<(p|br)>/,'<\1 />')
- para.gsub!(/<:br>/,'<br />')
- unless para =~/^<:code>/
+ #para.gsub!(/<(p|br)>/,'<\1 />')
+ unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/
if para =~/<::\s+/ #watch
para.gsub!(/<::\s+(\S+?)\s+!>/,
%{<img src="#{@env.url.images}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0">})
@@ -308,11 +314,11 @@ module SiSU_Tune
%{<img src="#{@env.url.images_local}/\\1" naturalsizeflag="0" align="bottom" border="0">})
end
if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/
- @word_mode=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|\S+/)
+ @word_mode=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|\S+/u)
words=urls(@word_mode)
para.gsub!(/.+/m,words)
end
- if (para !~/^0~|^<:code>/)
+ if (para !~/^#{Mx[:meta_o]}|^#{Mx[:gr_o]}code#{Mx[:gr_c]}/)
para.gsub!(/\\copyright/i,%{<sup>&copy;</sup>})
if (para !~/\<:ad\s+\.\.\//)
para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/,
@@ -327,11 +333,11 @@ module SiSU_Tune
para.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to&nbsp;{&nbsp;\1&nbsp;}</a> ')
if para =~/\b\S+\@\S+?\.\S+/ \
and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/
- para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'&lt;<a href="mailto:\1">\1</a>&gt;\2')
+ para.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'&lt;<a href="mailto:\1">\1</a>&gt;')
end
para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration
para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url
- para.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration
+ para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration
if para =~/..\/\S+/ \
and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/
para.gsub!(/(\.\.\/\S+)/,'<a href="\1">\1</a>')
@@ -349,14 +355,14 @@ module SiSU_Tune
data=@data
@tuned_file=[]
data.each do |para|
- unless para =~/^<:code>/
- para.gsub!(/(~[{])(\d+) (.+?) <#@dp>([}]~)/,
+ unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/
+ para.gsub!(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?) #{Mx[:id_o]}#@dp#{Mx[:id_c]}(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,
'&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
'\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched)
- para.gsub!(/(~\[)([*+]\d+) (.+?) <#@dp>(\]~)/,
+ para.gsub!(/(#{Mx[:en_b_o]})([*+]\d+)\s+(.+?) #{Mx[:id_o]}#@dp#{Mx[:id_c]}(#{Mx[:en_b_c]})/,
'&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
'\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched)
- para.gsub!(/(~\{)([*+]+) (.+?) <#@dp>(\}~)/,
+ para.gsub!(/(#{Mx[:en_a_o]})([*+]+)\s+(.+?) #{Mx[:id_o]}#@dp#{Mx[:id_c]}(#{Mx[:en_a_c]})/,
'&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
'\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2</sup></a> \3 \4') #endnote- note- (careful may have switched)
end