From 07ce34456d7df7ae1b91710463d7e21cf54f7dc4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 5 Feb 2014 00:39:18 -0500 Subject: v5 v6: html, name tag related (output "cleaning") --- lib/sisu/v5/html_format.rb | 24 ++++++++++++++++-------- lib/sisu/v6/html_format.rb | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/html_format.rb b/lib/sisu/v5/html_format.rb index 96567de5..0dc65a06 100644 --- a/lib/sisu/v5/html_format.rb +++ b/lib/sisu/v5/html_format.rb @@ -874,6 +874,7 @@ WOK attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o + @make=SiSU_Env::ProcessingSettings.new(@md) if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @@ -897,19 +898,19 @@ WOK p caller end end - @headnamed= (@headname ? %{} : nil) + @headnamed=(@headname ? %{} : nil) if @txt and not @txt.empty? @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end @p_num=ParagraphNumber.new(@md,@ocn) @vz=SiSU_Viz::Defaults.new - @make=SiSU_Env::ProcessingSettings.new(@md) end def nametags_scroll(dob) tags='' if defined? dob.tags \ and dob.tags.length > 0 # insert tags "hypertargets" dob.tags.each do |t| + t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier tags=tags << %{} end end @@ -920,7 +921,16 @@ WOK if defined? dob.tags \ and dob.tags.length > 0 # insert tags "hypertargets" dob.tags.each do |t| - tags=tags << %{} + t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier + if @make.build.html_strict? + tags=(t =~/^[#{Mx[:ocn_id_char]}]?[0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{}) + else + tags=(t =~/^[#{Mx[:ocn_id_char]}][0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{}) + end end end tags @@ -929,8 +939,8 @@ WOK hn=if @t_o.is ==:heading \ and not @t_o.name.empty? #determine use hn=(@t_o.is ==:heading) \ - ? (%{}) - : (%{}) + ? (%{}) + : (%{}) else nil end hn @@ -1017,7 +1027,7 @@ WOK
#{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} - #{@named}#{@txt} + #{@named}#{@txt}
} @@ -1131,8 +1141,6 @@ WOK #{@vz.table_close}} end def bold_heading - @txt=@txt.gsub(/[1-9]~(\S+)/,''). - gsub(/[1-9]~/,'') %{

#{@txt}

diff --git a/lib/sisu/v6/html_format.rb b/lib/sisu/v6/html_format.rb index e2fa7dc6..18d42e14 100644 --- a/lib/sisu/v6/html_format.rb +++ b/lib/sisu/v6/html_format.rb @@ -874,6 +874,7 @@ WOK attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url def initialize(md,t_o) @md,@t_o=md,t_o + @make=SiSU_Env::ProcessingSettings.new(@md) if t_o.is_a?(Hash) @txt =t_o[:txt] || nil @ocn =t_o[:ocn] || nil @@ -897,19 +898,19 @@ WOK p caller end end - @headnamed= (@headname ? %{} : nil) + @headnamed=(@headname ? %{} : nil) if @txt and not @txt.empty? @txt=@txt.gsub(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') end @p_num=ParagraphNumber.new(@md,@ocn) @vz=SiSU_Viz::Defaults.new - @make=SiSU_Env::ProcessingSettings.new(@md) end def nametags_scroll(dob) tags='' if defined? dob.tags \ and dob.tags.length > 0 # insert tags "hypertargets" dob.tags.each do |t| + t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier tags=tags << %{} end end @@ -920,7 +921,16 @@ WOK if defined? dob.tags \ and dob.tags.length > 0 # insert tags "hypertargets" dob.tags.each do |t| - tags=tags << %{} + t=t.gsub(/[^a-z0-9._-]/,'') #use for all html tags? consider limiting to strict? or implementing earlier + if @make.build.html_strict? + tags=(t =~/^[#{Mx[:ocn_id_char]}]?[0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{}) + else + tags=(t =~/^[#{Mx[:ocn_id_char]}][0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{}) + end end end tags @@ -929,8 +939,8 @@ WOK hn=if @t_o.is ==:heading \ and not @t_o.name.empty? #determine use hn=(@t_o.is ==:heading) \ - ? (%{}) - : (%{}) + ? (%{}) + : (%{}) else nil end hn @@ -1017,7 +1027,7 @@ WOK
#{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} - #{@named}#{@txt} + #{@named}#{@txt}
} @@ -1131,8 +1141,6 @@ WOK #{@vz.table_close}} end def bold_heading - @txt=@txt.gsub(/[1-9]~(\S+)/,''). - gsub(/[1-9]~/,'') %{

#{@txt}

-- cgit v1.2.3