Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toc link not working on github #338

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/prmd/templates/schemata.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
title = schemata['title'].split(' - ', 2).last
-%>
<%- unless options[:doc][:disable_title_and_description] %>
<a name="#resource-<%= resource %>"></a>
<a name="resource-<%= resource %>"></a>
## <%= title %>

<%- if schemata['stability'] && !schemata['stability'].empty? %>
Expand Down
2 changes: 1 addition & 1 deletion lib/prmd/templates/schemata/link.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
response_example = link['response_example']
link_schema_properties_template = Prmd::Template.load_template('link_schema_properties.md.erb', options[:template])
-%>
<a name="link-<%= link['method'] %>-<%= resource %>-<%= link['href'] %>"></a>
<a name="link-<%= link['method'].downcase %>-<%= resource %>-<%= build_link_path(schema, link) %>"></a>
### <%= title %> <%= link['title'] %>

<details>
Expand Down
2 changes: 1 addition & 1 deletion lib/prmd/templates/table_of_contents.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<% _, schemata = schema.dereference(property) %>
- <a href="#resource-<%= resource %>"><%= schemata['title'].split(' - ', 2).last %></a>
<% schemata.fetch('links', []).each do |l| %>
- <a href="#link-<%= l['method'] %>-<%= resource %>-<%= l['href'] %>"><%= l['method'] %> <%= build_link_path(schema, l) %></a>
- <a href="#link-<%= l['method'].downcase %>-<%= resource %>-<%= build_link_path(schema, l) %>"><%= l['method'] %> <%= build_link_path(schema, l) %></a>
<% end %>
<% end %>
5 changes: 3 additions & 2 deletions test/commands/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def test_render_for_toc

assert_match /^## The table of contents/, markdown
assert_match '<a href="#resource-app"', markdown
assert_match '- <a href="#link-POST-app-/apps">POST /apps', markdown
assert_match '<a name="link-POST-app-/apps"></a>', markdown
assert_match '<a name="resource-app"', markdown
assert_match '- <a href="#link-post-app-/apps">POST /apps', markdown
assert_match '<a name="link-post-app-/apps"></a>', markdown
end

def test_render_for_example_as_an_array
Expand Down