From d79d6050ce31f7d8d65a87be4008e11fae368770 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 5 Feb 2014 01:09:02 -0500 Subject: v5 v6: html, (output) cleaning --- lib/sisu/v5/html.rb | 3 ++- lib/sisu/v5/html_format.rb | 9 ++++++--- lib/sisu/v5/html_tune.rb | 13 ++++++++++++- lib/sisu/v6/html.rb | 3 ++- lib/sisu/v6/html_format.rb | 9 ++++++--- lib/sisu/v6/html_tune.rb | 13 ++++++++++++- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/lib/sisu/v5/html.rb b/lib/sisu/v5/html.rb index ef62b9bd..4a911d2c 100644 --- a/lib/sisu/v5/html.rb +++ b/lib/sisu/v5/html.rb @@ -623,7 +623,8 @@ WOK toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if defined? @md.creator.author - creator_endnote=@md.creator.author.gsub(/(\*+)/, + creator=SiSU_HTML_Tune::CleanHTML.new(@md.creator.author).clean_for_html + creator_endnote=creator.gsub(/(\*+)/, %{ \\1}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } diff --git a/lib/sisu/v5/html_format.rb b/lib/sisu/v5/html_format.rb index a933d091..e244bbb8 100644 --- a/lib/sisu/v5/html_format.rb +++ b/lib/sisu/v5/html_format.rb @@ -502,7 +502,8 @@ WOK end def rights def all - rights=@md.rights.all.gsub(/^\s*Copyright\s+\(C\)/,'Copyright © ') + rights=SiSU_HTML_Tune::CleanHTML.new(@md.rights.all).clean_for_html + rights=rights.gsub(/^\s*Copyright\s+\(C\)/,'Copyright © ') %{

Rights: #{rights}

} end @@ -977,7 +978,9 @@ WOK end def para_form_css(tag,attrib) # regular paragraphs shaped here ul=ulc='' - ul,ulc="

" if @tag =~/li/ + if tag =~/li/ + ul,ulc="" + end %{
#{@p_num.ocn_display} @@ -1250,7 +1253,7 @@ WOK note=$1 note=note.gsub(/[\s]+/m,' ') txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). - gsub(/ \d+<\/sup> /m,'') + gsub(/ \d+<\/sup> /m,'') end %{<#{tag} class="#{attrib}"> #{txt} #{note} diff --git a/lib/sisu/v5/html_tune.rb b/lib/sisu/v5/html_tune.rb index 84336861..39cbb708 100644 --- a/lib/sisu/v5/html_tune.rb +++ b/lib/sisu/v5/html_tune.rb @@ -104,6 +104,16 @@ module SiSU_HTML_Tune def initialize(html='') @html=html end + def clean_for_html + html=@html + str=if html.is_a?(String) + html + else html.obj + end + str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[<]/m,'<').gsub(/[>]/m,'>') + end def clean html=@html str=if html.is_a?(String) @@ -111,7 +121,8 @@ module SiSU_HTML_Tune else html.obj end str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). - gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[\\]{2}/m,'
') end end class Tune diff --git a/lib/sisu/v6/html.rb b/lib/sisu/v6/html.rb index f1651326..8c9869e2 100644 --- a/lib/sisu/v6/html.rb +++ b/lib/sisu/v6/html.rb @@ -623,7 +623,8 @@ WOK toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if defined? @md.creator.author - creator_endnote=@md.creator.author.gsub(/(\*+)/, + creator=SiSU_HTML_Tune::CleanHTML.new(@md.creator.author).clean_for_html + creator_endnote=creator.gsub(/(\*+)/, %{ \\1}) tmp_head=creator_endnote + "\n" txt_obj={ txt: tmp_head } diff --git a/lib/sisu/v6/html_format.rb b/lib/sisu/v6/html_format.rb index 63271d95..de5a7144 100644 --- a/lib/sisu/v6/html_format.rb +++ b/lib/sisu/v6/html_format.rb @@ -502,7 +502,8 @@ WOK end def rights def all - rights=@md.rights.all.gsub(/^\s*Copyright\s+\(C\)/,'Copyright © ') + rights=SiSU_HTML_Tune::CleanHTML.new(@md.rights.all).clean_for_html + rights=rights.gsub(/^\s*Copyright\s+\(C\)/,'Copyright © ') %{

Rights: #{rights}

} end @@ -977,7 +978,9 @@ WOK end def para_form_css(tag,attrib) # regular paragraphs shaped here ul=ulc='' - ul,ulc="

    \n ","\n
" if @tag =~/li/ + if tag =~/li/ + ul,ulc="
    \n ","\n
" + end %{
#{@p_num.ocn_display} @@ -1250,7 +1253,7 @@ WOK note=$1 note=note.gsub(/[\s]+/m,' ') txt=txt.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' '). - gsub(/ \d+<\/sup> /m,'') + gsub(/ \d+<\/sup> /m,'') end %{<#{tag} class="#{attrib}"> #{txt} #{note} diff --git a/lib/sisu/v6/html_tune.rb b/lib/sisu/v6/html_tune.rb index 516deaa5..42568a36 100644 --- a/lib/sisu/v6/html_tune.rb +++ b/lib/sisu/v6/html_tune.rb @@ -104,6 +104,16 @@ module SiSU_HTML_Tune def initialize(html='') @html=html end + def clean_for_html + html=@html + str=if html.is_a?(String) + html + else html.obj + end + str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[<]/m,'<').gsub(/[>]/m,'>') + end def clean html=@html str=if html.is_a?(String) @@ -111,7 +121,8 @@ module SiSU_HTML_Tune else html.obj end str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). - gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/[\\]{2}/m,'
') end end class Tune -- cgit v1.2.3