HTML is the only supported format for documentation pages in the Mashery CMS. However, Markdown has gained popularity in recent years as an alternative format for API and component documentation. It is used as the standard documentation format by Github, Atlassian Confluence, and Google Docs, to name a few. The purpose of this document is to demonstrate how to allow customers to author their API documentation in Markdown, and correctly render the content as HTML in the portal.
Step-by-step guide
-
Create a new documentation page in the CMS. Be sure to uncheck the Use TinyMCE option at the top of the page
-
Type/paste your markdown into the Body field and save your changes
-
Click the Advanced Options button
-
Add the following code in the Inline JavaScript section
if (!window.jQuery) { loadJS('//code.jquery.com/jquery-1.8.2.js', function() { var converter = new showdown.Converter(); var text = $(".section-body").text(); console.log(text); var html = converter.makeHtml(text); console.log(html); $(".section-body").html(html); }); }
-
Add the following URL in the Custom Javascript file field
https://cdnjs.cloudflare.com/ajax/libs/showdown/1.7.3/showdown.min.js
That's it!
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now