markdown.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_name")
  16. def _template_name_default(self):
  17. return "markdown"
  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. {
  26. "ExtractAttachmentsPreprocessor": {"enabled": True},
  27. "ExtractOutputPreprocessor": {"enabled": True},
  28. "NbConvertBase": {
  29. "display_data_priority": [
  30. "text/html",
  31. "text/markdown",
  32. "image/svg+xml",
  33. "text/latex",
  34. "image/png",
  35. "image/jpeg",
  36. "text/plain",
  37. ]
  38. },
  39. "HighlightMagicsPreprocessor": {"enabled": True},
  40. }
  41. )
  42. if super().default_config:
  43. c2 = super().default_config.copy()
  44. c2.merge(c)
  45. c = c2
  46. return c