enclose-title.js 431 B

12345678910111213
  1. 'use strict';
  2. module.exports = enclose;
  3. /* There is currently no way to support nested delimiters
  4. * across Markdown.pl, CommonMark, and GitHub (RedCarpet).
  5. * The following code supports Markdown.pl and GitHub.
  6. * CommonMark is not supported when mixing double- and
  7. * single quotes inside a title. */
  8. function enclose(title) {
  9. var delimiter = title.indexOf('"') === -1 ? '"' : '\'';
  10. return delimiter + title + delimiter;
  11. }