Markdown.js

  1. /**
  2. * @file
  3. * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
  4. * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
  5. * Github.js is freely distributable.
  6. */
  7. import Requestable from './Requestable';
  8. /**
  9. * Renders html from Markdown text
  10. */
  11. class Markdown extends Requestable {
  12. /**
  13. * construct a Markdown
  14. * @param {Requestable.auth} auth - the credentials to authenticate to GitHub
  15. * @param {string} [apiBase] - the base Github API URL
  16. * @return {Promise} - the promise for the http request
  17. */
  18. constructor(auth, apiBase) {
  19. super(auth, apiBase);
  20. }
  21. /**
  22. * Render html from Markdown text.
  23. * @see https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document
  24. * @param {Object} options - conversion options
  25. * @param {string} [options.text] - the markdown text to convert
  26. * @param {string} [options.mode=markdown] - can be either `markdown` or `gfm`
  27. * @param {string} [options.context] - repository name if mode is gfm
  28. * @param {Requestable.callback} [cb] - will receive the converted html
  29. * @return {Promise} - the promise for the http request
  30. */
  31. render(options, cb) {
  32. return this._request('POST', '/markdown', options, cb);
  33. }
  34. }
  35. module.exports = Markdown;