diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v5/html_format.rb | 24 | ||||
-rw-r--r-- | lib/sisu/v6/html_format.rb | 24 |
2 files changed, 32 insertions, 16 deletions
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> |