Skip to content

Commit

Permalink
Avoid transforming #/guide links in guides.
Browse files Browse the repository at this point in the history
Previously these old-style links were rendered disfunctional.
  • Loading branch information
nene committed May 24, 2013
1 parent 95a052f commit e4deaa1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/jsduck/guide_anchors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
7 changes: 6 additions & 1 deletion spec/guide_anchors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ def transform(html)
"<a href='http://example.com'>label</a>"
end

it "doesn't transform docs-app #! links " do
it "doesn't transform docs-app #! links" do
transform("<a href='#!/api/Ext.Base'>Ext.Base</a>").should ==
"<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>"
Expand Down

0 comments on commit e4deaa1

Please sign in to comment.