Commit 8ab351a5 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Strip extra HTML from guides TOC.

Some titles contain links, resulting in links-inside-links which is of
no good.
parent 274f7578
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -111,8 +111,9 @@ module JsDuck
      html.each_line do |line|
        if line =~ /^<h2>(.*)<\/h2>$/
          i += 1
          toc << "<li><a href='#!/guide/#{guide['name']}-section-#{i}'>#{$1}</a></li>\n"
          new_html << "<h2 id='#{guide['name']}-section-#{i}'>#{$1}</h2>\n"
          text = strip_tags($1)
          toc << "<li><a href='#!/guide/#{guide['name']}-section-#{i}'>#{text}</a></li>\n"
          new_html << "<h2 id='#{guide['name']}-section-#{i}'>#{text}</h2>\n"
        else
          new_html << line
        end
@@ -151,6 +152,9 @@ module JsDuck
      "guides/" + guide["name"] + "/icon.png"
    end

    def strip_tags(str)
      str.gsub(/<.*?>/, "")
    end
  end

end