Commit e4deaa14 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Avoid transforming #/guide links in guides.

Previously these old-style links were rendered disfunctional.
parent 95a052f9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ module JsDuck
  class GuideAnchors

    def self.transform(html, guide_name)
      html.gsub(/(<a\s+(?:[^<>]*\s+)?href=['"]#)([^!].*?)(['"])/i) do |m|
      html.gsub(/(<a\s+(?:[^<>]*\s+)?href=['"]#)([^!\/].*?)(['"])/i) do |m|
        "#{$1}!/guide/#{guide_name}-section-#{$2}#{$3}"

      end.gsub(/(<a\s+(?:[^<>]*\s+)?name=['"])(.*?)(['"])/i) do |m|
+6 −1
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ describe JsDuck::GuideAnchors do
      "<a href='#!/api/Ext.Base'>Ext.Base</a>"
  end

  it "doesn't transform docs-app (backwards-compatible) # links" do
    transform("<a href='#/api/Ext.Base'>Ext.Base</a>").should ==
      "<a href='#/api/Ext.Base'>Ext.Base</a>"
  end

  it "transforms anchors" do
    transform("<a name='blah'>target</a>").should ==
      "<a name='myguide-section-blah'>target</a>"