showdown.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. md.compilers.showdown = (() => {
  2. var defaults = null // see below
  3. var description = {
  4. disableForced4SpacesIndentedSublists: 'Disables the requirement of indenting nested sublists by 4 spaces',
  5. encodeEmails: 'Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities',
  6. ghCodeBlocks: 'Turn on/off GFM fenced code blocks support',
  7. ghCompatibleHeaderId: 'Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)',
  8. ghMentions: 'Enables github @mentions',
  9. literalMidWordUnderscores: 'Parse midword underscores as literal underscores',
  10. noHeaderId: 'Turn on/off generated header id',
  11. omitExtraWLInCodeBlocks: 'Omit the default extra whiteline added to code blocks',
  12. parseImgDimensions: 'Turn on/off image dimension parsing',
  13. prefixHeaderId: 'Specify a prefix to generated header ids',
  14. requireSpaceBeforeHeadingText: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
  15. simpleLineBreaks: 'Parses simple line breaks as <br> (GFM Style)',
  16. simplifiedAutoLink: 'Turn on/off GFM autolink style',
  17. smartIndentationFix: 'Tries to smartly fix indentation in es6 strings',
  18. smoothLivePreview: 'Prevents weird effects in live previews due to incomplete input',
  19. strikethrough: 'Turn on/off strikethrough support',
  20. tables: 'Turn on/off tables support',
  21. tablesHeaderId: 'Add an id to table headers',
  22. tasklists: 'Turn on/off GFM tasklist support',
  23. customizedHeaderId: 'Use text in curly braces as header id',
  24. rawPrefixHeaderId: 'Prevent modifying the prefix',
  25. rawHeaderId: 'Remove only spaces, \' and \' from generated header ids',
  26. tablesHeaderId: 'Adds an id property to table headers tags',
  27. openLinksInNewWindow: 'Open all links in new windows',
  28. backslashEscapesHTMLTags: 'Support for HTML Tag escaping',
  29. emoji: 'Enable emoji support',
  30. ellipsis: 'Replaces three dots with the ellipsis unicode character',
  31. metadata: 'Enable support for document metadata',
  32. splitAdjacentBlockquotes: 'Split adjacent blockquote blocks',
  33. }
  34. var flavor = (name) => {
  35. var options = showdown.getDefaultOptions()
  36. var flavor = showdown.getFlavorOptions(name)
  37. var result = {}
  38. for (var key in options) {
  39. result[key] = (flavor[key] !== undefined) ? flavor[key] : options[key]
  40. }
  41. return result
  42. }
  43. defaults = flavor('github')
  44. var ctor = ({storage: {state}}) => ({
  45. defaults,
  46. description,
  47. compile: (markdown) =>
  48. new showdown.Converter(state.showdown)
  49. .makeHtml(markdown)
  50. })
  51. return Object.assign(ctor, {defaults, description})
  52. })()