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

Added Markdown rendering #824

Merged
merged 1 commit into from
Jan 13, 2015
Merged
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
1,272 changes: 1,272 additions & 0 deletions lib/marked.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/main/coffeescript/SwaggerUi.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class SwaggerUi extends Backbone.Router
switch @options.docExpansion
when "full" then @expandAll()
when "list" then @listAll()
@renderGFM()
@options.onComplete(@api, @) if @options.onComplete
setTimeout(
=>
Expand Down Expand Up @@ -125,4 +126,9 @@ class SwaggerUi extends Backbone.Router
@options.onFailure(data) if @options.onFailure?
val

# Renders GFM for elements with 'markdown' class
renderGFM: (data = '') ->
$('.markdown').each (index) ->
$(this).html(marked($(this).html()))

window.SwaggerUi = SwaggerUi
1 change: 1 addition & 0 deletions src/main/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script src='lib/swagger-client.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<script src='lib/marked.js' type='text/javascript'></script>

<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
Expand Down
2 changes: 1 addition & 1 deletion src/main/template/main.handlebars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class='info' id='api_info'>
{{#if info}}
<div class="info_title">{{info.title}}</div>
<div class="info_description">{{{info.description}}}</div>
<div class="info_description markdown">{{{info.description}}}</div>
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
{{#if info.contact}}<div class='info_contact'><a href="mailto:{{info.contact.name}}">Contact the developer</a></div>{{/if}}
{{#if info.license}}<div class='info_license'><a href='{{info.license.url}}'>{{info.license.name}}</a></div>{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion src/main/template/operation.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{{/if}}
{{#if description}}
<h4>Implementation Notes</h4>
<p>{{{description}}}</p>
<p class="markdown">{{{description}}}</p>
{{/if}}
{{#oauth}}
<div class="auth">
Expand Down
2 changes: 1 addition & 1 deletion src/main/template/param.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{{/if}}

</td>
<td>{{{description}}}</td>
<td class="markdown">{{{description}}}</td>
<td>{{{paramType}}}</td>
<td>
<span class="model-signature"></span>
Expand Down
2 changes: 1 addition & 1 deletion src/main/template/param_list.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
{{/each}}
</select>
</td>
<td>{{{description}}}</td>
<td class="markdown">{{{description}}}</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
2 changes: 1 addition & 1 deletion src/main/template/param_readonly.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
{{/if}}
{{/if}}
</td>
<td>{{{description}}}</td>
<td class="markdown">{{{description}}}</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
2 changes: 1 addition & 1 deletion src/main/template/param_readonly_required.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
{{/if}}
{{/if}}
</td>
<td>{{{description}}}</td>
<td class="markdown">{{{description}}}</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
2 changes: 1 addition & 1 deletion src/main/template/param_required.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{/if}}
</td>
<td>
<strong>{{{description}}}</strong>
<strong><span class="markdown">{{{description}}}</span></strong>
</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>