Skip to content

Commit e4deaa1

Browse files
committed
Avoid transforming #/guide links in guides.
Previously these old-style links were rendered disfunctional.
1 parent 95a052f commit e4deaa1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/jsduck/guide_anchors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module JsDuck
88
class GuideAnchors
99

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

1414
end.gsub(/(<a\s+(?:[^<>]*\s+)?name=['"])(.*?)(['"])/i) do |m|

spec/guide_anchors_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ def transform(html)
2626
"<a href='http://example.com'>label</a>"
2727
end
2828

29-
it "doesn't transform docs-app #! links " do
29+
it "doesn't transform docs-app #! links" do
3030
transform("<a href='#!/api/Ext.Base'>Ext.Base</a>").should ==
3131
"<a href='#!/api/Ext.Base'>Ext.Base</a>"
3232
end
3333

34+
it "doesn't transform docs-app (backwards-compatible) # links" do
35+
transform("<a href='#/api/Ext.Base'>Ext.Base</a>").should ==
36+
"<a href='#/api/Ext.Base'>Ext.Base</a>"
37+
end
38+
3439
it "transforms anchors" do
3540
transform("<a name='blah'>target</a>").should ==
3641
"<a name='myguide-section-blah'>target</a>"

0 commit comments

Comments
 (0)