markdown.js 767 B

1234567891011121314151617181920212223242526272829303132333435
  1. var md = (function () {
  2. // marked
  3. var defaults = {
  4. gfm: true,
  5. // highlight: null,
  6. tables: true,
  7. breaks: false,
  8. pedantic: false,
  9. sanitize: true,
  10. smartLists: true,
  11. smartypants: false,
  12. langPrefix: 'language-'//prism
  13. }
  14. function compile (markdown, sendResponse) {
  15. chrome.storage.sync.get(function (sync) {
  16. marked.setOptions(sync.options)
  17. marked(markdown, function (err, html) {
  18. if (err) throw err
  19. // prism fix
  20. html = html.replace(/language-html/g, 'language-markup')
  21. html = html.replace(/language-js/g, 'language-javascript')
  22. sendResponse({message: 'marked', marked: html})
  23. })
  24. })
  25. }
  26. return {
  27. defaults: defaults,
  28. compile: compile
  29. }
  30. }())