markdown.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """Markdown Exporter class"""
  2. # Copyright (c) Jupyter Development Team.
  3. # Distributed under the terms of the Modified BSD License.
  4. from traitlets import default
  5. from traitlets.config import Config
  6. from .templateexporter import TemplateExporter
  7. class MarkdownExporter(TemplateExporter):
  8. """
  9. Exports to a markdown document (.md)
  10. """
  11. export_from_notebook = "Markdown"
  12. @default('file_extension')
  13. def _file_extension_default(self):
  14. return '.md'
  15. @default('template_file')
  16. def _template_file_default(self):
  17. return 'markdown.tpl'
  18. output_mimetype = 'text/markdown'
  19. @default('raw_mimetypes')
  20. def _raw_mimetypes_default(self):
  21. return ['text/markdown', 'text/html', '']
  22. @property
  23. def default_config(self):
  24. c = Config({
  25. 'ExtractOutputPreprocessor': {'enabled': True},
  26. 'NbConvertBase': {
  27. 'display_data_priority': ['text/html',
  28. 'text/markdown',
  29. 'image/svg+xml',
  30. 'text/latex',
  31. 'image/png',
  32. 'image/jpeg',
  33. 'text/plain'
  34. ]
  35. },
  36. 'HighlightMagicsPreprocessor': {
  37. 'enabled':True
  38. },
  39. })
  40. c.merge(super(MarkdownExporter, self).default_config)
  41. return c