diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-02-05 00:39:18 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-02-05 00:39:18 -0500 |
commit | 07ce34456d7df7ae1b91710463d7e21cf54f7dc4 (patch) | |
tree | 993553bb0151e843ca74239e09f3b06abf59f64f | |
parent | v5 v6: ao, set document tags (diff) |
v5 v6: html, name tag related (output "cleaning")
-rw-r--r-- | data/doc/sisu/CHANGELOG_v5 | 3 | ||||
-rw-r--r-- | data/doc/sisu/CHANGELOG_v6 | 3 | ||||
-rw-r--r-- | lib/sisu/v5/html_format.rb | 24 | ||||
-rw-r--r-- | lib/sisu/v6/html_format.rb | 24 |
4 files changed, 38 insertions, 16 deletions
diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index d20e150c..321ac1fb 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -40,6 +40,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.3.1.orig.tar.xz * ao, document tags +* html cleaning + * tags + * error/warn messages, including wrappers round require %% 5.3.0.orig.tar.xz (2014-01-26:03/7) diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index b7f8a379..0b2cf5e8 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -30,6 +30,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.1.orig.tar.xz * ao, document tags +* html cleaning + * tags + * error/warn messages, including wrappers round require %% 6.0.0.orig.tar.xz (2014-01-26:03/7) 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 ? %{<a name="h#{@headname}" id="h#{@headname}"></a>} : nil) + @headnamed=(@headname ? %{<a id="h#{@headname}"></a>} : 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 << %{<named id="#{t}" />} 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 << %{<a name="#{t}" ></a>} + 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 << %{<a name="#{t}" ></a>}) + else + tags=(t =~/^[#{Mx[:ocn_id_char]}][0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{<a name="#{t}" ></a>}) + 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) \ - ? (%{<a name="h#{@t_o.name}" id="h#{@t_o.name}"></a>}) - : (%{<a name="#{@t_o.name}" id="#{@t_o.name}"></a>}) + ? (%{<a id="h#{@t_o.name}"></a>}) + : (%{<a id="#{@t_o.name}"></a>}) else nil end hn @@ -1017,7 +1027,7 @@ WOK <div class="substance"> #{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} - #{@named}<a name="h#{@headname}">#{@txt}</a> + #{@named}#{@txt} </#{tag}> </div> } @@ -1131,8 +1141,6 @@ WOK #{@vz.table_close}} end def bold_heading - @txt=@txt.gsub(/[1-9]~(\S+)/,'<a name="\1"></a>'). - gsub(/[1-9]~/,'') %{<p class="bold"> #{@txt} </p> 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 ? %{<a name="h#{@headname}" id="h#{@headname}"></a>} : nil) + @headnamed=(@headname ? %{<a id="h#{@headname}"></a>} : 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 << %{<named id="#{t}" />} 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 << %{<a name="#{t}" ></a>} + 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 << %{<a name="#{t}" ></a>}) + else + tags=(t =~/^[#{Mx[:ocn_id_char]}][0-9.]+$/) \ + ? tags #check what can be sorted in ao + : (tags << %{<a name="#{t}" ></a>}) + 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) \ - ? (%{<a name="h#{@t_o.name}" id="h#{@t_o.name}"></a>}) - : (%{<a name="#{@t_o.name}" id="#{@t_o.name}"></a>}) + ? (%{<a id="h#{@t_o.name}"></a>}) + : (%{<a id="#{@t_o.name}"></a>}) else nil end hn @@ -1017,7 +1027,7 @@ WOK <div class="substance"> #{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} - #{@named}<a name="h#{@headname}">#{@txt}</a> + #{@named}#{@txt} </#{tag}> </div> } @@ -1131,8 +1141,6 @@ WOK #{@vz.table_close}} end def bold_heading - @txt=@txt.gsub(/[1-9]~(\S+)/,'<a name="\1"></a>'). - gsub(/[1-9]~/,'') %{<p class="bold"> #{@txt} </p> |